本文整理汇总了PHP中Cli::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Cli::getInstance方法的具体用法?PHP Cli::getInstance怎么用?PHP Cli::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cli
的用法示例。
在下文中一共展示了Cli::getInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public final function execute()
{
$hasThreads = function_exists('pcntl_signal');
if (!$hasThreads || Cli::getInstance()->isSimulation()) {
flush();
try {
return $this->executeNoThread();
} catch (Interrupt $e) {
throw $e;
} catch (Exception $e) {
echo $e;
}
return;
}
pcntl_signal(SIGCHLD, SIG_IGN);
$pid = pcntl_fork();
if ($pid < 1) {
$this->_run();
posix_kill(posix_getpid(), 9);
pcntl_waitpid(posix_getpid(), $temp = 0, WNOHANG);
pcntl_wifexited($temp);
exit;
//Make sure we exit...
} else {
$this->pid = $pid;
}
}
示例2: _showCliError
/**
* Stop script and outputs an error page in CLI mode
*
* @param string $type Type of error (the error page title)
* @param string $message Error message
* @param array $backtrace Array of parsed backtrace
* @return void
*/
private function _showCliError($type, $message, $backtrace)
{
$cli = Cli::getInstance();
$cli->printf('[' . $type . ']', 'red');
$cli->printf(' -> ' . $message . PHP_EOL);
$bt = $this->_parseBacktrace($backtrace);
$nb = count($bt);
foreach ($bt as $k => $line) {
$cli->printf('[debug' . $nb-- . ']', 'cyan');
$cli->printf(' -> ');
if (isset($line['exception'])) {
$cli->printf($line['exception']);
} else {
$cli->printf($line['function'] . '(' . $line['args'] . ')');
}
if (isset($line['line']) && isset($line['file'])) {
$cli->printf(' / ' . $line['file'] . ' ln.' . $line['line']);
}
$cli->printf(PHP_EOL);
}
die;
}
示例3: define
<?php
define("ROOT", dirname(__FILE__));
error_reporting(0);
include ROOT . '/include/AutoLoad.php';
Cli::getInstance()->run($argc, $argv);
示例4: isEnabled
$this->request = $this->data['request'];
$this->context = $this->data['context'];
$this->settings = $this->data['settings'];
}
}
public function isEnabled()
{
return $this->isEnabled;
}
public function getData()
{
return $this->data;
}
public function getRequest()
{
return $this->request;
}
public function getContext()
{
return $this->context;
}
public function getSettings()
{
return $this->settings;
}
private $data, $request, $context, $settings, $isEnabled;
public static $instance = null;
}
if (Cli::getInstance($argv)->isEnabled()) {
Graphene::getInstance()->start();
}
示例5: stopDaemon
public function stopDaemon($pidFile, $force = false)
{
$pid = @file_get_contents($pidFile);
if (!$pid) {
Cli::getInstance()->displayErrorAndExit('Pid file empty or not found!');
}
unlink($pidFile);
if ($force) {
$this->killPid($pid);
$this->displayLine('Daemon stopped forcefully');
} else {
$i = 0;
while (true) {
if ($i > 60) {
$this->displayLine('Daemon could not be stopped gracefully');
$this->killPid($pid);
$this->displayLine('Daemon stopped forcefully');
break;
}
if (!$this->isPidAlive($pid)) {
$this->displayLine('Daemon stopped gracefully');
break;
}
$i++;
sleep(1);
}
}
return true;
}
示例6:
<?php
//To be done - is to pre-compile a sites views
return;
require_once '../bootstrap.php';
Cli::getInstance()->setRequiredParams('path', 'base');
$path = Cli::getInstance()->getParam('path');
if (is_dir($path)) {
} else {
if (is_file($path)) {
} else {
Cli::getInstance()->displayErrorAndExit('Not a valid file or directory: ' . $path);
}
}