本文整理汇总了PHP中PHPDaemon\Core\Daemon::initSettings方法的典型用法代码示例。如果您正苦于以下问题:PHP Daemon::initSettings方法的具体用法?PHP Daemon::initSettings怎么用?PHP Daemon::initSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPDaemon\Core\Daemon
的用法示例。
在下文中一共展示了Daemon::initSettings方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareAsync
protected function prepareAsync()
{
EventLoop::init();
Daemon::initSettings();
FileSystem::init();
FileSystem::initEvent();
}
示例2: compatRunEmul
/**
* It allows to run your simple web-apps in spawn-fcgi/php-fpm environment.
* @return boolean|null - Success.
*/
public static function compatRunEmul()
{
Daemon::$compatMode = TRUE;
Daemon::initSettings();
$argv = isset($_SERVER['CMD_ARGV']) ? $_SERVER['CMD_ARGV'] : '';
$args = \PHPDaemon\Core\Bootstrap::getArgs($argv);
if (isset($args[$k = 'configfile'])) {
Daemon::$config[$k] = $args[$k];
}
if (!Daemon::$config->loadCmdLineArgs($args)) {
$error = true;
}
if (isset(Daemon::$config->configfile->value) && !Daemon::loadConfig(Daemon::$config->configfile->value)) {
$error = true;
}
if (!isset(Daemon::$config->path->value)) {
exit('\'path\' is not defined');
}
if ($error) {
exit;
}
$appResolver = (require Daemon::$config->path->value);
$appResolver->init();
$req = new \stdClass();
$req->attrs = new \stdClass();
$req->attrs->request = $_REQUEST;
$req->attrs->get = $_GET;
$req->attrs->post = $_REQUEST;
$req->attrs->cookie = $_REQUEST;
$req->attrs->server = $_SERVER;
$req->attrs->files = $_FILES;
$req->attrs->session = isset($_SESSION) ? $_SESSION : null;
$req->attrs->connId = 1;
$req->attrs->trole = 'RESPONDER';
$req->attrs->flags = 0;
$req->attrs->id = 1;
$req->attrs->paramsDone = true;
$req->attrs->inputDone = true;
$req = $appResolver->getRequest($req);
while (true) {
$ret = $req->call();
if ($ret === 1) {
return;
}
}
}
示例3: init
/**
* Actions on early startup.
* @param string Optional. Config file path.
* @return void
*/
public static function init($configFile = null)
{
if (!version_compare(PHP_VERSION, '5.4.0', '>=')) {
Daemon::log('PHP >= 5.4.0 required.');
return;
}
//run without composer
if (!function_exists('setTimeout')) {
require 'PHPDaemon/Utils/func.php';
}
Daemon::initSettings();
FileSystem::init();
Daemon::$runName = basename($_SERVER['argv'][0]);
$error = FALSE;
$argv = $_SERVER['argv'];
$runmode = isset($argv[1]) ? str_replace('-', '', $argv[1]) : '';
$args = Bootstrap::getArgs($argv);
if (!isset(self::$params[$runmode]) && !in_array($runmode, self::$commands)) {
if ('' !== $runmode) {
echo 'Unrecognized command: ' . $runmode . "\n";
}
self::printUsage();
exit;
} elseif ('help' === $runmode) {
self::printHelp();
exit;
}
$n = null;
if ('log' === $runmode) {
if (isset($args['n'])) {
$n = $args['n'];
unset($args['n']);
} else {
$n = 20;
}
}
if (isset($configFile)) {
Daemon::$config->configfile->setHumanValue($configFile);
}
if (isset($args['configfile'])) {
Daemon::$config->configfile->setHumanValue($args['configfile']);
}
if (!Daemon::$config->loadCmdLineArgs($args)) {
$error = true;
}
if (!Daemon::loadConfig(Daemon::$config->configfile->value)) {
$error = true;
}
if ('log' === $runmode) {
passthru('tail -n ' . $n . ' -f ' . escapeshellarg(Daemon::$config->logstorage->value));
exit;
}
if (extension_loaded('apc') && ini_get('apc.enabled')) {
Daemon::log('Detected pecl-apc extension enabled. Usage of bytecode caching (APC/eAccelerator/xcache/...) makes no sense at all in case of using phpDaemon \'cause phpDaemon includes files just in time itself.');
}
if (isset(Daemon::$config->locale->value) && Daemon::$config->locale->value !== '') {
setlocale(LC_ALL, array_map('trim', explode(',', Daemon::$config->locale->value)));
}
if (Daemon::$config->autoreimport->value && !is_callable('runkit_import')) {
Daemon::log('[WARN] runkit extension not found. You should install it or disable --auto-reimport. Non-critical error.');
}
if (!is_callable('posix_kill')) {
Daemon::log('[EMERG] Posix not found. You should compile PHP without \'--disable-posix\'.');
$error = true;
}
if (!is_callable('pcntl_signal')) {
Daemon::log('[EMERG] PCNTL not found. You should compile PHP with \'--enable-pcntl\'.');
$error = true;
}
if (extension_loaded('libevent')) {
Daemon::log('[EMERG] libevent extension found. You have to remove libevent.so extension.');
$error = true;
}
$eventVer = '1.6.1';
$eventVerType = 'stable';
if (!Daemon::loadModuleIfAbsent('event', $eventVer . '-' . $eventVerType)) {
Daemon::log('[EMERG] event extension >= ' . $eventVer . ' not found (or OUTDATED). You have to install it. `pecl install http://pecl.php.net/get/event`');
$error = true;
}
if (!is_callable('socket_create')) {
Daemon::log('[EMERG] Sockets extension not found. You should compile PHP with \'--enable-sockets\'.');
$error = true;
}
if (!is_callable('shmop_open')) {
Daemon::log('[EMERG] Shmop extension not found. You should compile PHP with \'--enable-shmop\'.');
$error = true;
}
if (!isset(Daemon::$config->user)) {
Daemon::log('[EMERG] You must set \'user\' parameter.');
$error = true;
}
if (!isset(Daemon::$config->path)) {
Daemon::log('[EMERG] You must set \'path\' parameter (path to your application resolver).');
$error = true;
}
//.........这里部分代码省略.........