當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CLI類代碼示例

本文整理匯總了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");
    }
}
開發者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


注:本文中的CLI類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。