本文整理汇总了PHP中task函数的典型用法代码示例。如果您正苦于以下问题:PHP task函数的具体用法?PHP task怎么用?PHP task使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了task函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadRecipe
protected function loadRecipe()
{
require __DIR__ . '/../../recipe/common.php';
task('deploy:timeout_test', function () {
$this->result = run('sleep 11 && echo $SSH_CLIENT');
});
task('deploy:ssh_test', function () {
$this->result = run('echo $SSH_CLIENT');
});
task('deploy:agent_test', function () {
$this->result = run('ssh -T deployer@localhost \'echo $SSH_CLIENT\'');
});
}
示例2: desc
<?php
/* (c) Samuel Gordalina <samuel.gordalina@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Deployer;
desc('Notifying New Relic of deployment');
task('deploy:newrelic', function () {
global $php_errormsg;
$config = get('newrelic', array());
if (!is_array($config) || !isset($config['license']) || !isset($config['app_name']) && !isset($config['application_id'])) {
throw new \RuntimeException("<comment>Please configure new relic:</comment> <info>set('newrelic', array('license' => 'xad3...', 'application_id' => '12873'));</info>");
}
$git = array('user' => trim(runLocally('git config user.name')), 'revision' => trim(runLocally('git log -n 1 --format="%h"')), 'description' => trim(runLocally('git log -n 1 --format="%an: %s" | tr \'"\' "\'"')));
$postdata = array_merge($git, $config);
unset($postdata['license']);
$options = array('http' => array('method' => 'POST', 'header' => "Content-type: application/x-www-form-urlencoded\r\n" . "X-License-Key: {$config['license']}\r\n", 'content' => http_build_query(array('deployment' => $postdata))));
$context = stream_context_create($options);
$result = @file_get_contents('https://api.newrelic.com/deployments.xml', false, $context);
if ($result === false) {
throw new \RuntimeException($php_errormsg);
}
});
示例3: set
<?php
namespace Deployer;
require_once __DIR__ . '/common.php';
/**
* Silverstripe configuration
*/
// Silverstripe shared dirs
set('shared_dirs', ['assets']);
// Silverstripe writable dirs
set('writable_dirs', ['assets']);
/**
* Helper tasks
*/
task('silverstripe:build', function () {
return run('{{bin/php}} {{release_path}}/framework/cli-script.php /dev/build');
})->desc('Run /dev/build');
task('silverstripe:buildflush', function () {
return run('{{bin/php}} {{release_path}}/framework/cli-script.php /dev/build flush=all');
})->desc('Run /dev/build?flush=all');
/**
* Main task
*/
task('deploy', ['deploy:prepare', 'deploy:lock', 'deploy:release', 'deploy:update_code', 'deploy:vendors', 'deploy:shared', 'deploy:writable', 'silverstripe:buildflush', 'deploy:symlink', 'deploy:unlock', 'cleanup'])->desc('Deploy your project');
after('deploy', 'success');
示例4: server
require 'recipe/drupal8.php';
server('prod', '146.185.128.63', 9999)->user('deploy')->identityFile()->stage('production')->env('deploy_path', '/usr/share/nginx/html/kristiankaadk');
set('repository', 'git@github.com:kaa4ever/kristiankaadk.git');
task('deploy:permissions', function () {
run('if [ -d {{deploy_path}}/shared ]; then sudo chown -R deploy:deploy {{deploy_path}}/shared; fi');
run('if [ -d {{deploy_path}}/releases ]; then sudo chown -R deploy:deploy {{deploy_path}}/releases; fi');
});
task('docker:reboot', function () {
cd('{{release_path}}');
run('docker stop kristiankaa.site || true');
run('docker rm kristiankaa.site || true');
run('docker-compose -f docker-compose.prod.yml up -d');
});
task('drush:make', function () {
writeln("<info>Drush: Building site</info>");
run('docker exec kristiankaa.site bash -c "cd /var/www/html && drush make site.make -y"');
});
task('drush:updb', function () {
writeln("<info>Drush: Updating database</info>");
run('docker exec kristiankaa.site drush updb -y --root=/var/www/html');
});
task('drush:cache', function () {
writeln("<info>Drush: Rebuilding cache</info>");
run('docker exec kristiankaa.site drush cr --root=/var/www/html');
});
after('deploy:prepare', 'deploy:permissions');
after('deploy:update_code', 'docker:reboot');
after('deploy:update_code', 'drush:make');
after('deploy', 'drush:updb');
after('deploy', 'drush:cache');
示例5: option
<?php
use Deployer\Database\Database;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
option('from', null, InputOption::VALUE_OPTIONAL, 'The source server for copying the instance');
task('copy:database', function () {
if (!input()->getOption('from')) {
throw new Exception('The source server is required');
}
$from = input()->getArgument('stage');
if ($from == 'production') {
throw new \Exception('That is strictly prohibited to restore the dump to the production server');
}
/** @var string $dump */
$dump = Database::loadUsingStage($from)->dump();
Database::loadUsingStage(input()->getOption('from'))->restore($dump);
run("rm -f " . $dump);
});
task('copy', ['copy:database']);
示例6: catch
}
}
} catch (\RuntimeException $e) {
}
return $opts;
});
desc('Migrating database by phinx');
task('phinx:migrate', function () {
$ALLOWED_OPTIONS = ['configuration', 'date', 'environment', 'target', 'parser'];
$conf = get('phinx_get_allowed_config')($ALLOWED_OPTIONS);
cd('{{release_path}}');
$phinxCmd = get('phinx_get_cmd')('migrate', $conf);
run($phinxCmd);
cd('{{deploy_path}}');
});
task('phinx:rollback', function () {
$ALLOWED_OPTIONS = ['configuration', 'date', 'environment', 'target', 'parser'];
$conf = get('phinx_get_allowed_config')($ALLOWED_OPTIONS);
cd('{{release_path}}');
$phinxCmd = get('phinx_get_cmd')('rollback', $conf);
run($phinxCmd);
cd('{{deploy_path}}');
});
task('phinx:seed', function () {
$ALLOWED_OPTIONS = ['configuration', 'environment', 'parser', 'seed'];
$conf = get('phinx_get_allowed_config')($ALLOWED_OPTIONS);
cd('{{release_path}}');
$phinxCmd = get('phinx_get_cmd')('seed:run', $conf);
run($phinxCmd);
cd('{{deploy_path}}');
});
示例7: env
<?php
/* (c) Anton Medvedev <anton@medv.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once __DIR__ . '/common.php';
// Flow-Framework application-context
env('flow_context', 'Production');
// Flow-Framework cli-command
env('flow_command', 'flow');
// Flow-Framework shared directories
set('shared_dirs', ['Data/Persistent', 'Data/Logs', 'Configuration/{{flow_context}}']);
/**
* Apply database migrations
*/
task('deploy:run_migrations', function () {
run('FLOW_CONTEXT={{flow_context}} {{bin/php}} {{release_path}}/{{flow_command}} doctrine:migrate');
})->desc('Apply database migrations');
/**
* Publish resources
*/
task('deploy:publish_resources', function () {
run('FLOW_CONTEXT={{flow_context}} {{bin/php}} {{release_path}}/{{flow_command}} resource:publish');
})->desc('Publish resources');
/**
* Main task
*/
task('deploy', ['deploy:prepare', 'deploy:release', 'deploy:update_code', 'deploy:vendors', 'deploy:shared', 'deploy:run_migrations', 'deploy:publish_resources', 'deploy:symlink', 'cleanup'])->desc('Deploy your project');
after('deploy', 'success');
示例8: run
run("echo '<?php' > {{release_path}}/db.php");
run("echo 'return [' >> {{release_path}}/db.php");
run("echo \" 'class' => 'yii\\db\\Connection',\" >> {{release_path}}/db.php");
run("echo \" 'dsn' => 'mysql:host=localhost;dbname=test_dep_aaaaa',\" >> {{release_path}}/db.php");
run("echo \" 'username' => 'test',\" >> {{release_path}}/db.php");
run("echo \" 'password' => '',\" >> {{release_path}}/db.php");
run("echo \" 'charset' => 'utf8',\" >> {{release_path}}/db.php");
run("echo \"];\" >> {{release_path}}/db.php");
})->desc('Configure database connection');
/**
* Run migrations
*/
task('deploy:run_migrations', function () {
run('{{bin/php}} {{release_path}}/yii migrate up --interactive=0');
})->desc('Run migrations');
/**
* Main task
*/
task('deploy', ['deploy:prepare', 'deploy:release', 'deploy:update_code', 'deploy:shared', 'deploy:vendors', 'deploy:configure_db', 'deploy:run_migrations', 'deploy:symlink', 'deploy:writable', 'cleanup'])->desc('Deploy your project');
after('deploy', 'success');
/**
* Restart php-fpm on success deploy.
*/
//task('php-fpm:restart', function () {
// // Attention: The user must have rights for restart service
// // Attention: the command "sudo /bin/systemctl restart php-fpm.service" used only on CentOS system
// // /etc/sudoers: username ALL=NOPASSWD:/bin/systemctl restart php-fpm.service
// run('sudo /bin/systemctl restart php-fpm.service');
//})->desc('Restart PHP-FPM service');
//
//after('success', 'php-fpm:restart');
示例9: desc
desc('Execute artisan view:clear');
task('artisan:view:clear', function () {
run('{{bin/php}} {{release_path}}/artisan view:clear');
});
desc('Execute artisan optimize');
task('artisan:optimize', function () {
run('{{bin/php}} {{release_path}}/artisan optimize');
});
/**
* Task deploy:public_disk support the public disk.
* To run this task automatically, please add below line to your deploy.php file
*
* before('deploy:symlink', 'deploy:public_disk');
*
* @see https://laravel.com/docs/5.2/filesystem#configuration
*/
desc('Make symlink for public disk');
task('deploy:public_disk', function () {
// Remove from source.
run('if [ -d $(echo {{release_path}}/public/storage) ]; then rm -rf {{release_path}}/public/storage; fi');
// Create shared dir if it does not exist.
run('mkdir -p {{deploy_path}}/shared/storage/app/public');
// Symlink shared dir to release dir
run('{{bin/symlink}} {{deploy_path}}/shared/storage/app/public {{release_path}}/public/storage');
});
/**
* Main task
*/
desc('Deploy your project');
task('deploy', ['deploy:prepare', 'deploy:lock', 'deploy:release', 'deploy:update_code', 'deploy:shared', 'deploy:vendors', 'deploy:writable', 'artisan:view:clear', 'artisan:cache:clear', 'artisan:config:cache', 'artisan:optimize', 'deploy:symlink', 'deploy:unlock', 'cleanup']);
after('deploy', 'success');
示例10: set
* file that was distributed with this source code.
*/
namespace Deployer;
require_once __DIR__ . '/common.php';
/**
* CakePHP 3 Project Template configuration
*/
// CakePHP 3 Project Template shared dirs
set('shared_dirs', ['logs', 'tmp']);
// CakePHP 3 Project Template shared files
set('shared_files', ['config/app.php']);
/**
* Create plugins' symlinks
*/
task('deploy:init', function () {
run('{{release_path}}/bin/cake plugin assets symlink');
})->desc('Initialization');
/**
* Run migrations
*/
task('deploy:run_migrations', function () {
run('{{release_path}}/bin/cake migrations migrate');
run('{{release_path}}/bin/cake orm_cache clear');
run('{{release_path}}/bin/cake orm_cache build');
})->desc('Run migrations');
/**
* Main task
*/
task('deploy', ['deploy:prepare', 'deploy:lock', 'deploy:release', 'deploy:update_code', 'deploy:shared', 'deploy:vendors', 'deploy:init', 'deploy:run_migrations', 'deploy:symlink', 'deploy:unlock', 'cleanup'])->desc('Deploy your project');
after('deploy', 'success');
示例11: task
<?php
namespace Bob\BuildConfig;
task("default", array("test"));
desc("Runs all tests.");
task("test", array("phpunit.xml", "composer.json"), function () {
sh("./vendor/bin/phpunit");
});
fileTask("phpunit.xml", array("phpunit.dist.xml"), function ($task) {
copy($task->prerequisites[0], $task->name);
});
fileTask("composer.json", array("composer.lock"), function ($task) {
if (!file_exists("composer.phar")) {
file_put_contents("composer.phar", file_get_contents("http://getcomposer.org/composer.phar"));
}
php("composer.phar install --dev");
});
示例12: task
task('cachetool:clear:apc', function () {
$releasePath = env('release_path');
$env = env();
$options = $env->has('cachetool') ? $env->get('cachetool') : get('cachetool');
if (strlen($options)) {
$options = "--fcgi={$options}";
}
cd($releasePath);
$hasCachetool = run("if [ -e {$releasePath}/cachetool.phar ]; then echo 'true'; fi");
if ('true' !== $hasCachetool) {
run("curl -sO http://gordalina.github.io/cachetool/downloads/cachetool.phar");
}
run("{{bin/php}} cachetool.phar apc:cache:clear system {$options}");
})->desc('Clearing APC system cache');
/**
* Clear opcache cache
*/
task('cachetool:clear:opcache', function () {
$releasePath = env('release_path');
$env = env();
$options = $env->has('cachetool') ? $env->get('cachetool') : get('cachetool');
if (strlen($options)) {
$options = "--fcgi={$options}";
}
cd($releasePath);
$hasCachetool = run("if [ -e {$releasePath}/cachetool.phar ]; then echo 'true'; fi");
if ('true' !== $hasCachetool) {
run("curl -sO http://gordalina.github.io/cachetool/downloads/cachetool.phar");
}
run("{{bin/php}} cachetool.phar opcache:reset {$options}");
})->desc('Clearing OPcode cache');
示例13: env
env('current', function () {
return run("readlink {{deploy_path}}/current")->toString();
});
/**
* Show current release number.
*/
task('current', function () {
writeln('Current release: ' . basename(env('current')));
})->desc('Show current release.');
/**
* Cleanup old releases.
*/
task('cleanup', function () {
$releases = env('releases_list');
$keep = get('keep_releases');
while ($keep > 0) {
array_shift($releases);
--$keep;
}
foreach ($releases as $release) {
run("rm -rf {{deploy_path}}/releases/{$release}");
}
run("cd {{deploy_path}} && if [ -e release ]; then rm release; fi");
run("cd {{deploy_path}} && if [ -h release ]; then rm release; fi");
})->desc('Cleaning up old releases');
/**
* Success message
*/
task('success', function () {
writeln("<info>Successfully deployed!</info>");
})->once()->setPrivate();
示例14: task
<?php
/* (c) Sergio Carracedo <info@sergiocarraedo.es>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Deployer;
require_once __DIR__ . '/common.php';
task('deploy', ['deploy:prepare', 'deploy:lock', 'deploy:release', 'deploy:update_code', 'deploy:shared', 'deploy:symlink', 'deploy:unlock', 'cleanup']);
//Set drupal site. Change if you use different site
set('drupal_site', 'default');
//Drupal 8 shared dirs
set('shared_dirs', ['sites/{{drupal_site}}/files']);
//Drupal 8 shared files
set('shared_files', ['sites/{{drupal_site}}/settings.php', 'sites/{{drupal_site}}/services.yml']);
//Drupal 8 Writable dirs
set('writable_dirs', ['sites/{{drupal_site}}/files']);
示例15: set
<?php
/* (c) Anton Medvedev <anton@medv.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Deployer;
set('bin/npm', function () {
return (string) run('which npm');
});
desc('Install npm packages');
task('npm:install', function () {
$releases = get('releases_list');
if (isset($releases[1])) {
if (run("if [ -d {{deploy_path}}/releases/{$releases[1]}/node_modules ]; then echo 'true'; fi")->toBool()) {
run("cp --recursive {{deploy_path}}/releases/{$releases[1]}/node_modules {{release_path}}");
}
}
run("cd {{release_path}} && {{bin/npm}} install");
});