PHP Class PHPDaemon\Core\Daemon

Author: Zorin Vasily ([email protected])
Inheritance: use trait PHPDaemon\Traits\ClassWatchdog, use trait PHPDaemon\Traits\StaticObjectWatchdog
Show file Open project: kakserpom/phpdaemon Class Usage Examples

Public Properties

Property Type Description
$appInstances array Running application instances
$appResolver AppResolver AppResolver
$appResolverPath string Path to application resolver
$compatMode boolean Running under Apache/PHP-FPM in compatibility mode?
$config PHPDaemon\Config\Object Configuration object
$context object Running context
$defaultErrorLevel integer Default error reporting level
$logpointer resource Log file resource
$logpointerAsync object Log file async. resource
$noError boolean Mechanism of catching errors. Set it to true, then run your suspect code, and then check this property again. If false, there was error message.
$obInStack boolean Whether if the current execution stack contains ob-filter
$process PHPDaemon\Thread\Master | PHPDaemon\Thread\IPC | PHPDaemon\Thread\Worker Current thread object
$req PHPDaemon\Request\Generic Running request
$restrictErrorControl boolean Restrict error control. When true, operator '@' means nothing.
$runName string Base name of daemon instance
$runworkerMode boolean Is it running under master-less 'runworker' mode?
$shm_wstate PHPDaemon\Thread\Collection Shared memory 'WSTATE' entity
$startTime integer PHPDaemon start time
$version string PHPDaemon version
$wstateRev array Hash of possible worker states

Protected Properties

Property Type Description
$initservervar array Copy of $_SERVER on the daemon start
$masters PHPDaemon\Thread\Collection Collection of masters
$support string Supported things array
$workers PHPDaemon\Thread\Collection Collection of workers

Public Methods

Method Description
callAutoGC ( ) : void Call automatic garbage collector
checkAutoGC ( ) : boolean Check if we need to run automatic garbage collector
compatRunEmul ( ) : boolean | null It allows to run your simple web-apps in spawn-fcgi/php-fpm environment.
errorHandler ( integer $errno, string $errstr, string $errfile, integer $errline, array $errcontext ) Error handler
getStateOfWorkers ( ) : array Get state of workers.
glob ( string $pattern, integer $flags ) : array Glob function with support of include_path
init ( ) : void Performs initial actions.
initSettings ( ) : void Loads default setting.
lintFile ( $filename ) : boolean Check file syntax via runkit_lint_file if supported or via php -l
loadConfig ( string $paths ) : boolean Load config-file
loadModuleIfAbsent ( string $mod, string $version = null, string $compare = '>=' ) : boolean Load PHP extension (module) if absent
log ( $args ) Send message to the log
openLogs ( ) : void Open logs
outputFilter ( $s ) : string Output filter
runWorker ( ) : void Run worker thread
spawnMaster ( ) : null | integer Spawn a master process
supported ( integer $what ) : boolean Is thing supported
uncaughtExceptionHandler ( Exception $e ) : void Uncaught exception handler
uniqid ( ) : string Generate a unique ID.

Protected Methods

Method Description
checkSupports ( ) : void Method to fill $support array

Method Details

callAutoGC() public static method

Call automatic garbage collector
public static callAutoGC ( ) : void
return void

checkAutoGC() public static method

Check if we need to run automatic garbage collector
public static checkAutoGC ( ) : boolean
return boolean

checkSupports() protected static method

Method to fill $support array
protected static checkSupports ( ) : void
return void

compatRunEmul() public static method

It allows to run your simple web-apps in spawn-fcgi/php-fpm environment.
public static compatRunEmul ( ) : boolean | null
return boolean | null - Success.

errorHandler() public static method

Error handler
public static errorHandler ( integer $errno, string $errstr, string $errfile, integer $errline, array $errcontext )
$errno integer
$errstr string
$errfile string
$errline integer
$errcontext array

getStateOfWorkers() public static method

Get state of workers.
public static getStateOfWorkers ( ) : array
return array - information.

glob() public static method

Glob function with support of include_path
public static glob ( string $pattern, integer $flags ) : array
$pattern string
$flags integer
return array

init() public static method

Performs initial actions.
public static init ( ) : void
return void

initSettings() public static method

Loads default setting.
public static initSettings ( ) : void
return void

lintFile() public static method

Check file syntax via runkit_lint_file if supported or via php -l
public static lintFile ( $filename ) : boolean
return boolean

loadConfig() public static method

Load config-file
public static loadConfig ( string $paths ) : boolean
$paths string Path
return boolean - Success.

loadModuleIfAbsent() public static method

Load PHP extension (module) if absent
public static loadModuleIfAbsent ( string $mod, string $version = null, string $compare = '>=' ) : boolean
$mod string
$version string
$compare string
return boolean $success

log() public static method

Send message to the log
public static log ( $args )
$args

openLogs() public static method

Open logs
public static openLogs ( ) : void
return void

outputFilter() public static method

Output filter
public static outputFilter ( $s ) : string
return string Output

runWorker() public static method

Run worker thread
public static runWorker ( ) : void
return void

spawnMaster() public static method

Spawn a master process
public static spawnMaster ( ) : null | integer
return null | integer - success

supported() public static method

Is thing supported
public static supported ( integer $what ) : boolean
$what integer Thing to check
return boolean

uncaughtExceptionHandler() public static method

Uncaught exception handler
public static uncaughtExceptionHandler ( Exception $e ) : void
$e Exception
return void

uniqid() public static method

Generate a unique ID.
public static uniqid ( ) : string
return string Returns the unique identifier, as a string.

Property Details

$appInstances public static property

Running application instances
public static array $appInstances
return array

$appResolver public static property

AppResolver
public static AppResolver,PHPDaemon\Core $appResolver
return AppResolver

$appResolverPath public static property

Path to application resolver
public static string $appResolverPath
return string

$compatMode public static property

Running under Apache/PHP-FPM in compatibility mode?
public static bool $compatMode
return boolean

$config public static property

Configuration object
public static Object,PHPDaemon\Config $config
return PHPDaemon\Config\Object

$context public static property

Running context
public static object $context
return object

$defaultErrorLevel public static property

Default error reporting level
public static int $defaultErrorLevel
return integer

$initservervar protected static property

Copy of $_SERVER on the daemon start
protected static array $initservervar
return array

$logpointer public static property

Log file resource
public static resource $logpointer
return resource

$logpointerAsync public static property

Log file async. resource
public static object $logpointerAsync
return object

$masters protected static property

Collection of masters
protected static Collection,PHPDaemon\Thread $masters
return PHPDaemon\Thread\Collection

$noError public static property

Mechanism of catching errors. Set it to true, then run your suspect code, and then check this property again. If false, there was error message.
public static bool $noError
return boolean

$obInStack public static property

Whether if the current execution stack contains ob-filter
public static bool $obInStack
return boolean

$process public static property

Current thread object
public static Master,PHPDaemon\Thread|IPC,PHPDaemon\Thread|Worker,PHPDaemon\Thread $process
return PHPDaemon\Thread\Master | PHPDaemon\Thread\IPC | PHPDaemon\Thread\Worker

$req public static property

Running request
public static Generic,PHPDaemon\Request $req
return PHPDaemon\Request\Generic

$restrictErrorControl public static property

Restrict error control. When true, operator '@' means nothing.
public static bool $restrictErrorControl
return boolean

$runName public static property

Base name of daemon instance
public static string $runName
return string

$runworkerMode public static property

Is it running under master-less 'runworker' mode?
public static bool $runworkerMode
return boolean

$shm_wstate public static property

Shared memory 'WSTATE' entity
public static Collection,PHPDaemon\Thread $shm_wstate
return PHPDaemon\Thread\Collection

$startTime public static property

PHPDaemon start time
public static int $startTime
return integer

$support protected static property

Supported things array
protected static string $support
return string

$version public static property

PHPDaemon version
public static string $version
return string

$workers protected static property

Collection of workers
protected static Collection,PHPDaemon\Thread $workers
return PHPDaemon\Thread\Collection

$wstateRev public static property

Hash of possible worker states
public static array $wstateRev
return array