当前位置: 首页>>代码示例>>PHP>>正文


PHP Cli::getInstance方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:27,代码来源:Thread.php

示例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;
 }
开发者ID:salomalo,项目名称:php-oxygen,代码行数:30,代码来源:error.class.php

示例3: define

<?php

define("ROOT", dirname(__FILE__));
error_reporting(0);
include ROOT . '/include/AutoLoad.php';
Cli::getInstance()->run($argc, $argv);
开发者ID:freedream520,项目名称:Psearch,代码行数:6,代码来源:cli.php

示例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();
}
开发者ID:GrapheneProject,项目名称:Graphene,代码行数:31,代码来源:cli.php

示例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;
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:29,代码来源:Cli.php

示例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);
    }
}
开发者ID:hofmeister,项目名称:Pimple,代码行数:14,代码来源:compile.php


注:本文中的Cli::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。