本文整理汇总了PHP中desc函数的典型用法代码示例。如果您正苦于以下问题:PHP desc函数的具体用法?PHP desc怎么用?PHP desc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了desc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: desc
<?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;
desc('Cleaning up files and/or directories');
task('deploy:clear_paths', function () {
$paths = get('clear_paths');
$sudo = get('clear_use_sudo') ? 'sudo' : '';
foreach ($paths as $path) {
run("{$sudo} rm -rf {{release_path}}/{$path}");
}
});
示例2: desc
<?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;
desc('Rollback to previous release');
task('rollback', function () {
$releases = get('releases_list');
if (isset($releases[1])) {
$releaseDir = "{{deploy_path}}/releases/{$releases[1]}";
// Symlink to old release.
run("cd {{deploy_path}} && {{bin/symlink}} {$releaseDir} current");
// Remove release
run("rm -rf {{deploy_path}}/releases/{$releases[0]}");
if (isVerbose()) {
writeln("Rollback to `{$releases[1]}` release was successful.");
}
} else {
writeln("<comment>No more releases you can revert to.</comment>");
}
});
示例3: p
p(2);
});
});
desc('bleem');
task('bleem', function () {
p(0);
});
after('bleem:baz', function () {
p(3);
});
desc('foo');
task('foo', function () {
p(5);
});
desc('bar');
task('bar', function () {
p(8);
});
task('foo', function () {
p(6);
});
before('foo', function () {
p(4);
});
after('foo', function () {
p(7);
});
task('foo', 'bleem:baz');
desc('default');
task('default', 'foo');
task('default', 'bar');
示例4: desc
<?php
/* (c) David Jordan / CyberDuck <david@cyber-duck.co.uk>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Deployer;
desc('Clearing Cloudflare Cache');
task('deploy:cloudflare', function () {
$config = get('cloudflare', []);
//validate config and set headers
if (!empty($config['service_key'])) {
$headers = ['X-Auth-User-Service-Key' => $config['service_key']];
} elseif (!empty($config['email']) && !empty($config['api_key'])) {
$headers = ['X-Auth-Key' => $config['api_key'], 'X-Auth-Email' => $config['email']];
} else {
throw new \RuntimeException("Set a service key or email / api key");
}
$headers['Content-Type'] = 'application/json';
if (empty($config['domain'])) {
throw new RuntimeException("Set a domain");
}
$makeRequest = function ($url, $opts = []) use($headers) {
$ch = curl_init("https://api.cloudflare.com/client/v4/{$url}");
foreach ($headers as $key => $value) {
$parsedHeaders[] = "{$key}: {$value}";
}
curl_setopt_array($ch, [CURLOPT_HTTPHEADER => $parsedHeaders, CURLOPT_RETURNTRANSFER => true]);
curl_setopt_array($ch, $opts);
示例5: 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);
}
});
示例6: desc
<?php
desc("start selenium");
task("selenium:run", null, function ($argv) {
$path = ROOT . "vendor/Selenium-Server/selenium-server.jar";
system("java -jar {$path}");
});
desc("test one test");
task("test", null, function ($argv) {
Tab\Tab::addIncludePaths(ROOT . "test/", ROOT . "test/Midori");
require "tests-bootstrap.php";
$argv = $argv->args;
if (count($argv) == 1) {
$args = array("Single Test");
foreach ($argv as $item) {
$args[] = $item;
}
}
$_SERVER['argv'] = $args;
require_once 'PHPUnit/Util/Filter.php';
require_once 'Midori/PHPUnit/Spec.php';
PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
require 'PHPUnit/TextUI/Command.php';
define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main');
PHPUnit_TextUI_Command::main();
});
示例7: set
<?php
/* (c) Laurent Goussard <loranger@free.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Deployer;
/**
* Get local username
*/
set('local_user', function () {
return trim(run("whoami"));
});
desc('Notifying Rollbar of deployment');
task('deploy:rollbar', function () {
global $php_errormsg;
$defaultConfig = ['access_token' => null, 'environment' => get('stages')[0], 'revision' => trim(runLocally('git log -n 1 --format="%h"')), 'local_username' => trim(runLocally('git config user.name')), 'rollbar_username' => null, 'comment' => "Deployment to `{{host}}` on *{{stage}}* was successful\n({{release_path}})"];
$config = array_merge($defaultConfig, (array) get('rollbar', []));
if (!is_array($config) || !isset($config['access_token'])) {
throw new \RuntimeException("Please configure new rollbar: set('rollbar', ['access_token' => 'c09a3...', 'revision' => 'v4.3', 'rollbar_username' => 'John Doe', 'comment' => 'Brand new version']);");
}
$server = \Deployer\Task\Context::get()->getServer();
if ($server instanceof \Deployer\Server\Local) {
$user = get('local_user');
} else {
$user = $server->getConfiguration()->getUser() ?: null;
}
$commentPlaceHolders = ['{{release_path}}' => get('release_path'), '{{host}}' => get('server.host'), '{{stage}}' => get('stages')[0], '{{user}}' => $user, '{{branch}}' => get('branch')];
$config['comment'] = strtr($config['comment'], $commentPlaceHolders);
示例8: desc
<?php
/**
* file create task
*/
desc("File create task");
task("create_file", function () {
touch("/tmp/hogehoge");
});
desc("File delete task");
task("delete_file", array("create_file"), function () {
unlink("/tmp/hogehoge");
});
示例9: desc
<?php
/* (c) Tim Robertson <funkjedi@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 Bugsnag of deployment');
task('deploy:bugsnag', function () {
global $php_errormsg;
$defaultConfig = ['api_key' => null, 'release_stage' => get('stages')[0], 'repository' => get('repository'), 'provider' => null, 'branch' => get('branch'), 'revision' => trim(runLocally('git log -n 1 --format="%h"')), 'app_version' => null];
$config = array_merge($defaultConfig, (array) get('bugsnag'));
if (!is_array($config) || !isset($config['api_key'])) {
throw new \RuntimeException("Please configure new bugsnag: set('bugsnag', ['api_key' => 'c09a3...', 'release_stage' => 'production']);");
}
$postdata = ['apiKey' => $config['api_key'], 'releaseStage' => $config['release_stage'], 'repository' => $config['repository'], 'provider' => $config['provider'], 'branch' => $config['branch'], 'revision' => $config['revision'], 'appVersion' => $config['app_version']];
$options = array('http' => array('method' => 'POST', 'header' => "Content-type: application/json\r\n", 'content' => json_encode($postdata)));
$context = stream_context_create($options);
$result = @file_get_contents('https://notify.bugsnag.com/deploy', false, $context);
if (!$result) {
throw new \RuntimeException($php_errormsg);
}
});
示例10: desc
<?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;
desc('Preparing server for deploy');
task('deploy:prepare', function () {
// Check if shell is POSIX-compliant
try {
cd('');
// To run command as raw.
$result = run('echo $0')->toString();
if ($result == 'stdin: is not a tty') {
throw new \RuntimeException("Looks like ssh inside another ssh.\n" . "Help: http://goo.gl/gsdLt9");
}
} catch (\RuntimeException $e) {
$formatter = Deployer::get()->getHelper('formatter');
$errorMessage = ["Shell on your server is not POSIX-compliant. Please change to sh, bash or similar.", "Usually, you can change your shell to bash by running: chsh -s /bin/bash"];
write($formatter->formatBlock($errorMessage, 'error', true));
throw $e;
}
run('if [ ! -d {{deploy_path}} ]; then mkdir -p {{deploy_path}}; fi');
// Check for existing /current directory (not symlink)
$result = run('if [ ! -L {{deploy_path}}/current ] && [ -d {{deploy_path}}/current ]; then echo true; fi')->toBool();
if ($result) {
throw new \RuntimeException('There already is a directory (not symlink) named "current" in ' . get('deploy_path') . '. Remove this directory so it can be replaced with a symlink for atomic deployments.');
}
示例11: implode
}
return implode(' ', $optionsRsync);
});
desc('Warmup remote Rsync target');
task('rsync:warmup', function () {
$config = get('rsync');
$releases = get('releases_list');
if (isset($releases[1])) {
$source = "{{deploy_path}}/releases/{$releases[1]}";
$destination = "{{deploy_path}}/releases/{$releases[0]}";
run("rsync -{$config['flags']} {{rsync_options}}{{rsync_excludes}}{{rsync_includes}}{{rsync_filter}} {$source}/ {$destination}/");
} else {
writeln("<comment>No way to warmup rsync.</comment>");
}
});
desc('Rsync local->remote');
task('rsync', function () {
$config = get('rsync');
$src = get('rsync_src');
while (is_callable($src)) {
$src = $src();
}
if (!trim($src)) {
// if $src is not set here rsync is going to do a directory listing
// exiting with code 0, since only doing a directory listing clearly
// is not what we want to achieve we need to throw an exception
throw new \RuntimeException('You need to specify a source path.');
}
$dst = get('rsync_dest');
while (is_callable($dst)) {
$dst = $dst();
示例12: desc
<?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;
desc('Cleaning up old releases');
task('cleanup', function () {
$releases = get('releases_list');
$keep = get('keep_releases');
if ($keep === -1) {
// Keep unlimited releases.
return;
}
while ($keep - 1 > 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");
});
示例13: desc
<?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;
desc('Installing vendors');
task('deploy:vendors', function () {
run('cd {{release_path}} && {{env_vars}} {{bin/composer}} {{composer_options}}');
});
示例14: desc
<?php
/**
* directory task
*/
desc("Directory Create task");
task("create_dir", function () {
mkdir("/tmp/hogehoge");
});
desc("Directory delete task");
task("delete_dir", array("create_dir"), function () {
rmdir("/tmp/hogehoge");
});
示例15: task
<?php
/*
* Put the `bob_config.php` into the "Bob" namespace,
* otherwise you would've to call the `task` and
* `desc` functions with a `Bob\` prefix.
*/
namespace Bob\BuildConfig;
task('default', array('test'));
desc("Runs all tests");
task('test', array('composer.lock'), function () {
if (!file_exists('phpunit.xml')) {
copy('phpunit.dist.xml', 'phpunit.xml');
}
echo sh('phpunit');
});
desc('Runs "composer update" when the composer.json was changed');
fileTask('composer.lock', array('composer.json'), function ($task) {
echo sh('composer update');
});