本文整理汇总了PHP中CLI类的典型用法代码示例。如果您正苦于以下问题:PHP CLI类的具体用法?PHP CLI怎么用?PHP CLI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CLI类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: runHotfixInstall
function runHotfixInstall($command, $args)
{
CLI::logging("HOTFIX", PATH_DATA . "log" . PATH_SEP . "upgrades.log");
CLI::logging("Install hotfix to system\n");
$arrayFile = $command;
if (count($arrayFile) > 0) {
//Install hotfix
foreach ($arrayFile as $value) {
$f = $value;
$result = workspaceTools::hotfixInstall($f);
CLI::logging($result["message"] . "\n");
}
//Clear server's cache
CLI::logging("\nClearing cache...\n");
if (defined("PATH_C")) {
G::rm_dir(PATH_C);
G::mk_dir(PATH_C, 0777);
}
//Safe upgrade for JavaScript files
CLI::logging("\nSafe upgrade for files cached by the browser\n\n");
G::browserCacheFilesSetUid();
CLI::logging("HOTFIX done\n");
} else {
CLI::logging("Please specify the hotfix to install\n");
}
}
开发者ID:emildev35,项目名称:processmaker,代码行数:26,代码来源:cliHotfix.php
示例2: run_create_translation
function run_create_translation($args, $opts)
{
G::LoadSystem('inputfilter');
$filter = new InputFilter();
$opts = $filter->xssFilterHard($opts);
$args = $filter->xssFilterHard($args);
$rootDir = realpath(__DIR__."/../../../../");
$app = new Maveriks\WebApplication();
$app->setRootDir($rootDir);
$loadConstants = false;
$workspaces = get_workspaces_from_args($args);
$lang = array_key_exists("lang", $opts) ? $opts['lang'] : 'en';
$translation = new Translation();
CLI::logging("Updating labels Mafe ...\n");
foreach ($workspaces as $workspace) {
try {
echo "Updating labels for workspace " . pakeColor::colorize($workspace->name, "INFO") . "\n";
$translation->generateTransaltionMafe($lang);
} catch (Exception $e) {
echo "Errors upgrading labels for workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n";
}
}
CLI::logging("Create successful\n");
}
开发者ID:hpx2206,项目名称:processmaker-1,代码行数:28,代码来源:cliMafe.php
示例3: __construct
public function __construct()
{
parent::__construct();
// Load argc and argv
$argc = Arr::get($_SERVER, 'argc') - 3;
$argv = array_slice(Arr::get($_SERVER, 'argv'), 3);
if ($argc > 0) {
$extends = CLI::options('i');
$extends = Arr::get($extends, 'i');
$generate_all = CLI::options('i');
for ($i = 0; $i < $argc; $i++) {
if (strpos($argv[$i], '--') !== FALSE) {
unset($argv[$i]);
}
}
$filename = Arr::get($argv, 0);
$methods = array_slice($argv, 1);
$this->generate($filename, $methods, $extends);
if ($generate_all) {
new Terminal_Model();
new Terminal_View();
}
} else {
$str = 'Missing controller name.';
echo Terminal::color($str, 'red') . PHP_EOL;
}
}
开发者ID:jaroslawziolkowski,项目名称:kohana-cli,代码行数:27,代码来源:controller.php
示例4: execute
public function execute($parameters, $db)
{
var_dump($db);
$commands = array();
$dir = __DIR__;
if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." && $entry != "base.php" && $entry != "cli_methods.php") {
$s1 = explode("cli_", $entry);
$s2 = explode(".php", $s1[1]);
if (sizeof($s2) == 2) {
require_once "{$dir}/{$entry}";
$command = $s2[0];
$className = "cli_{$command}";
$class = new $className();
if (is_a($class, "cliCommand")) {
$commands[] = $command;
}
}
}
}
closedir($handle);
}
sort($commands);
CLI::out("|g|Commands available: |n|" . implode(", ", $commands));
}
开发者ID:Covert-Inferno,项目名称:zKillboard,代码行数:26,代码来源:cli_list.php
示例5: run_update
function run_update($command, $args)
{
CLI::logging("Updating...\n");
$language = new Language();
$language->updateLanguagePlugin($command[0], $command[1]);
CLI::logging("Update successful\n");
}
开发者ID:emildev35,项目名称:processmaker,代码行数:7,代码来源:cliPlugins.php
示例6: warning
public static function warning($text)
{
$return = "\n";
$return .= CLI::color($text, 'white', 'yellow') . "\n";
$return .= "\n";
return $return;
}
开发者ID:haifai-labs,项目名称:repel-orm,代码行数:7,代码来源:CLI.php
示例7: run_flush_cache
function run_flush_cache($args, $opts)
{
$rootDir = realpath(__DIR__."/../../../../");
$app = new Maveriks\WebApplication();
$app->setRootDir($rootDir);
$loadConstants = false;
$workspaces = get_workspaces_from_args($args);
if (! defined("PATH_C")) {
die("ERROR: seems processmaker is not properly installed (System constants are missing).".PHP_EOL);
}
CLI::logging("Flush ".pakeColor::colorize("system", "INFO")." cache ... ");
G::rm_dir(PATH_C);
G::mk_dir(PATH_C, 0777);
echo "DONE" . PHP_EOL;
foreach ($workspaces as $workspace) {
echo "Flush workspace " . pakeColor::colorize($workspace->name, "INFO") . " cache ... ";
G::rm_dir($workspace->path . "/cache");
G::mk_dir($workspace->path . "/cache", 0777);
G::rm_dir($workspace->path . "/cachefiles");
G::mk_dir($workspace->path . "/cachefiles", 0777);
echo "DONE" . PHP_EOL;
}
}
开发者ID:hpx2206,项目名称:processmaker-1,代码行数:27,代码来源:cliFlushCache.php
示例8: execute
public function execute($parameters, $db)
{
global $base;
chdir($base);
if (sizeof($parameters) == 0 || $parameters[0] == "") {
CLI::out("Usage: |g|help <command>|n| To see a list of commands, use: |g|list", true);
}
$command = $parameters[0];
switch ($command) {
case "all":
// Cleanup old sessions
$db->execute("delete from zz_users_sessions where validTill < now()");
$killsLastHour = $db->queryField("select count(*) count from zz_killmails where insertTime > date_sub(now(), interval 1 hour)", "count");
Storage::store("KillsLastHour", $killsLastHour);
$db->execute("delete from zz_analytics where dttm < date_sub(now(), interval 24 hour)");
$fc = new FileCache("{$base}/cache/queryCache/");
$fc->cleanUp();
break;
case "killsLastHour":
$killsLastHour = $db->queryField("select count(*) count from zz_killmails where insertTime > date_sub(now(), interval 1 hour)", "count");
Storage::store("KillsLastHour", $killsLastHour);
break;
case "fileCacheClean":
$fc = new FileCache();
$fc->cleanUp();
break;
}
}
开发者ID:Covert-Inferno,项目名称:zKillboard,代码行数:28,代码来源:cli_minutely.php
示例9: after
/**
* Automatically executed after the task action.
*
* @return void
*/
protected function after()
{
if ($this->auto_render === TRUE and $this->template instanceof View) {
// Render and display template
CLI::write($this->template->render());
}
parent::after();
}
开发者ID:wintersilence,项目名称:kohana-cli,代码行数:13,代码来源:Template.php
示例10: before
public function before()
{
if (!Kohana::$is_cli) {
Request::instance()->redirect('/');
exit;
}
$auth = CLI::options('username', 'password');
$user = ORM::factory('user');
$status = $user->login($auth);
if (!$status) {
echo "You did not authenticate.\n";
exit;
}
}
开发者ID:natgeo,项目名称:kids-myshot,代码行数:14,代码来源:maintenance.php
示例11: before
/**
* Prevent Minion from being run over http
*/
public function before()
{
if (!Kohana::$is_cli) {
throw new Kohana_Exception("Minion can only be ran from the cli");
}
$this->_task = $this->request->param('task');
$options = CLI::options('help', 'task');
if (array_key_exists('help', $options)) {
$this->request->action('help');
}
if (!empty($options['task'])) {
$this->_task = $options['task'];
}
return parent::before();
}
开发者ID:reflectivedevelopment,项目名称:jfh-lib,代码行数:18,代码来源:minion.php
示例12: execute
public function execute($parameters, $db)
{
// Fix unknown group ID's
$result = $db->query("select distinct killID from zz_participants where groupID != vGroupID and isVictim = 1 limit 1", array(), 0);
foreach ($result as $row) {
$killID = $row["killID"];
$shipTypeID = $db->queryField("select shipTypeID from zz_participants where killID = {$killID} and isVictim = 1", "shipTypeID");
if ($shipTypeID == 0) {
continue;
}
$groupID = Info::getGroupID($shipTypeID);
echo "Updating {$killID} to {$groupID}\n";
$db->execute("update zz_participants set vGroupID = {$groupID} where killID = {$killID}");
}
CLI::out(sizeof($result) . " done!", true);
}
开发者ID:Covert-Inferno,项目名称:zKillboard,代码行数:16,代码来源:cli_fixGroupIDs.php
示例13: minify_javascript
function minify_javascript($command, $args)
{
CLI::logging("BUILD-JS\n");
//disabling the rakefile version, until we have updated the dev environment
//CLI::logging("Checking if rake is installed...\n");
//$rakeFile = PROCESSMAKER_PATH . "workflow/engine/bin/tasks/Rakefile";
//system('rake -f ' . $rakeFile);
require_once PATH_THIRDPARTY . 'jsmin/jsmin.php';
$libraries = json_decode(file_get_contents(PATH_HOME . 'engine/bin/tasks/libraries.json'));
//print_r($libraries);
foreach ($libraries as $k => $library) {
$build = $library->build;
if ($build) {
$bufferMini = "";
$sum1 = 0;
$sum2 = 0;
$libName = $library->name;
$files = $library->libraries;
$js_path = $library->build_js_to;
printf("Processing %s library:\n", $libName);
foreach ($files as $file) {
printf(" %-20s ", $file->name);
$fileNameMini = PATH_TRUNK . $file->mini;
if ($file->minify) {
$minify = JSMin::minify(file_get_contents($fileNameMini));
} else {
$minify = file_get_contents($fileNameMini);
}
$bufferMini .= $minify;
$size1 = filesize($fileNameMini);
$size2 = strlen($minify);
$sum1 += $size1;
$sum2 += $size2;
printf("%7d -> %7d %5.2f%%\n", $size1, $size2, 100 - $size2 / $size1 * 100);
}
if (substr($library->build_js_to, -1) != '/') {
$library->build_js_to .= '/';
}
$outputMiniFile = PATH_TRUNK . $library->build_js_to . $libName . ".js";
file_put_contents($outputMiniFile, $bufferMini);
printf(" -------------------- ------- ------- ------\n");
printf(" %-20s %7d -> %7d %6.2f%%\n", $libName . '.js', $sum1, $sum2, 100 - $sum2 / $sum1 * 100);
print " {$outputMiniFile}\n";
}
}
CLI::logging("BUILD-JS DONE\n");
}
开发者ID:rodrigoivan,项目名称:processmaker,代码行数:47,代码来源:cliRake.php
示例14: __construct
public function __construct()
{
parent::__construct();
// Load argc and argv
$argc = Arr::get($_SERVER, 'argc') - 3;
$argv = array_slice(Arr::get($_SERVER, 'argv'), 3);
if ($argc > 0) {
// Get model file
$filename = Arr::get($argv, 0);
// Get model extends
$extends = CLI::options('e');
$extends = Arr::get($extends, 'e');
$this->generate($filename, $extends);
} else {
$str = 'Missing model name.';
echo Terminal::color($str, 'red') . PHP_EOL;
}
}
开发者ID:jaroslawziolkowski,项目名称:kohana-cli,代码行数:18,代码来源:model.php
示例15: handler
/**
* Inline exception handler.
*
* - Display the error message, source of the exception
* - Stack trace of the error
* - Write error in [Log]
*
* @param Exception $e
* @return void
*/
public static function handler(Exception $e)
{
try {
$error = $e instanceof CLI_Exception ? $e->_cli_text() : parent::text($e);
CLI::error($error);
$exit_code = $e->getCode();
if ($exit_code == 0) {
// Never exit '0' after an exception
$exit_code = 1;
}
exit($exit_code);
} catch (Exception $e) {
// Display the exception text
CLI::error(parent::text($e));
// Exit with an error status
exit(1);
}
}
开发者ID:wintersilence,项目名称:kohana-cli,代码行数:28,代码来源:Exception.php
示例16: execute
public function execute($parameters, $db)
{
if (sizeof($parameters) == 0 || $parameters[0] == "") {
CLI::out("Usage: |g|recentStatsAndRanks <type>|n| To see a list of commands, use: |g|methods calculateAllTimeStatsAndRanks", true);
}
$command = $parameters[0];
switch ($command) {
case "all":
self::stats($db);
self::ranks($db);
break;
case "ranks":
self::ranks($db);
break;
case "stats":
self::stats($db);
break;
}
}
开发者ID:Covert-Inferno,项目名称:zKillboard,代码行数:19,代码来源:cli_calculateAllTimeStatsAndRanks.php
示例17: execute
public function execute($parameters, $db)
{
if (sizeof($parameters) == 0 || $parameters[0] == "") {
CLI::out("Usage: |g|help <command>|n| To see a list of commands, use: |g|list", true);
}
$command = $parameters[0];
$base = __DIR__;
$fileName = "{$base}/cli_{$command}.php";
if (!file_exists($fileName)) {
CLI::out("|r|Error running {$command}|n|. Please use list to show all commands, or help <command> to see information on how to use the command", true);
}
require_once $fileName;
$className = "cli_{$command}";
$class = new $className();
if (!is_a($class, "cliCommand")) {
CLI::out("|r| Module {$command} does not implement interface cliCommand", true);
}
$descr = $class->getDescription();
CLI::out("|g|{$command}:|n| {$descr}");
}
开发者ID:Covert-Inferno,项目名称:zKillboard,代码行数:20,代码来源:cli_help.php
示例18: testAppRoute
public function testAppRoute()
{
CLI::bash(['php brood app:module test_module']);
$has_file = file_exists($file = config()->path->app . 'TestModule/Routes.php');
$this->assertTrue($has_file, 'check if [' . $file . '] were generated');
$has_file = file_exists($file = config()->path->app . 'TestModule/Routes/RouteGroup.php');
$this->assertTrue($has_file, 'check if [' . $file . '] were generated');
$file_contents = file_get_contents($file);
$this->assertContains('namespace App\\TestModule\\Routes;', $file_contents);
$this->assertContains('use Phalcon\\Mvc\\Router\\Group as BaseRouteGroup;', $file_contents);
$this->assertContains('class RouteGroup extends BaseRouteGroup', $file_contents);
$has_file = file_exists($file = config()->path->app . 'TestModule/Providers/RouterServiceProvider.php');
$this->assertTrue($has_file, 'check if [' . $file . '] were generated');
$file_contents = file_get_contents($file);
$this->assertContains('namespace App\\TestModule\\Providers;', $file_contents);
$this->assertContains('use Phalcon\\Di\\FactoryDefault;', $file_contents);
$this->assertContains('use Clarity\\Providers\\ServiceProvider;', $file_contents);
$this->assertContains('use Clarity\\Contracts\\Providers\\ModuleInterface;', $file_contents);
$this->assertContains('class RouterServiceProvider extends ServiceProvider implements ModuleInterface', $file_contents);
$this->assertContains('public function module(FactoryDefault $di)', $file_contents);
$this->assertContains('->setDefaultNamespace(\'App\\TestModule\\Controllers\');', $file_contents);
$this->assertContains('public function afterModuleRun()', $file_contents);
$this->assertContains('require_once realpath(__DIR__.\'/../\').\'/Routes.php\';', $file_contents);
CLI::bash(['php brood app:route test test_module']);
$has_file = file_exists($file = config()->path->app . 'TestModule/Routes/TestRoutes.php');
$this->assertTrue($has_file, 'check if [' . $file . '] were generated');
$file_contents = file_get_contents($file);
$this->assertContains('namespace App\\TestModule\\Routes;', $file_contents);
$this->assertContains('class TestRoutes extends RouteGroup', $file_contents);
CLI::bash(['php brood app:controller test test_module']);
$has_file = file_exists($file = config()->path->app . 'TestModule/Controllers/TestController.php');
$this->assertTrue($has_file, 'check if [' . $file . '] were generated');
$file_contents = file_get_contents($file);
$this->assertContains('namespace App\\TestModule\\Controllers;', $file_contents);
$this->assertContains('class TestController extends Controller', $file_contents);
}
开发者ID:phalconslayer,项目名称:framework,代码行数:36,代码来源:AppTest.php
示例19: validate
{$create}
');
}
public static function validate(\$data){
return Check::valid([
{$valids}
], \$data);
}
}
EOC;
$models[$table] = $model;
}
$force = CLI::input('force', false);
foreach ($models as $table => $model) {
$file = dirname(__DIR__) . "/models/{$model->name}.php";
if (!$force && file_exists($file)) {
CLI::writeln("<red>Already founded a model named <b>{$model->name}</b>, skipping...</red>");
} else {
CLI::writeln("<green>Compiling</green> model : <b>{$model->name}</b>");
file_put_contents($file, $model->code);
}
}
break;
default:
echo "Model utilities.", PHP_EOL;
echo "- Available actions: generate --force", PHP_EOL;
break;
}
});
开发者ID:caffeina-core,项目名称:base-application,代码行数:31,代码来源:model.php
示例20: migrateList
/**
* Migrate all cases to New list
*
* return all LIST TABLES with data
*/
public function migrateList ($workSpace)
{
if ($this->listFirstExecution('check')) {
return 1;
}
$this->initPropel(true);
$appCache = new AppCacheView();
$users = new Users();
G::LoadClass("case");
$case = new Cases();
//Select data CANCELLED
$canCriteria = $appCache->getSelAllColumns();
$canCriteria->add(AppCacheViewPeer::APP_STATUS, "CANCELLED", CRITERIA::EQUAL);
$canCriteria->add(AppCacheViewPeer::DEL_LAST_INDEX, "1", CRITERIA::EQUAL);
$rsCriteria = AppCacheViewPeer::doSelectRS($canCriteria);
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
//Insert data LIST_CANCELED
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$listCanceled = new ListCanceled();
$listCanceled->remove($row["APP_UID"]);
$listCanceled->setDeleted(false);
$listCanceled->create($row);
}
CLI::logging("> Completed table LIST_CANCELED\n");
//Select data COMPLETED
$comCriteria = $appCache->getSelAllColumns();
$comCriteria->add(AppCacheViewPeer::APP_STATUS, "COMPLETED", CRITERIA::EQUAL);
$comCriteria->add(AppCacheViewPeer::DEL_LAST_INDEX, "1", CRITERIA::EQUAL);
$rsCriteria = AppCacheViewPeer::doSelectRS($comCriteria);
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
//Insert new data LIST_COMPLETED
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$listCompleted = new ListCompleted();
$listCompleted->remove($row["APP_UID"]);
$listCompleted->setDeleted(false);
$listCompleted->create($row);
}
CLI::logging("> Completed table LIST_COMPLETED\n");
//Select data TO_DO OR DRAFT
$inbCriteria = $appCache->getSelAllColumns();
//.........这里部分代码省略.........
开发者ID:rrsc,项目名称:processmaker,代码行数:101,代码来源:class.wsTools.php
注:本文中的CLI类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论