本文整理汇总了PHP中CLI类的典型用法代码示例。如果您正苦于以下问题:PHP CLI类的具体用法?PHP CLI怎么用?PHP CLI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CLI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
}
示例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");
}
示例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;
}
}
示例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));
}
示例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");
}
示例6: warning
public static function warning($text)
{
$return = "\n";
$return .= CLI::color($text, 'white', 'yellow') . "\n";
$return .= "\n";
return $return;
}
示例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;
}
}
示例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;
}
}
示例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();
}
示例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;
}
}
示例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();
}
示例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);
}
示例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");
}
示例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;
}
}
示例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);
}
}