PHP Class PHPPM\ProcessSlave

Show file Open project: php-pm/php-pm

Public Properties

Property Type Description
$slave ProcessSlave Current instance, used by global functions.

Protected Properties

Property Type Description
$appBootstrap string
$baseServer array Copy of $_SERVER during bootstrap.
$bridge PHPPM\Bridges\BridgeInterface
$bridgeName string
$config array 'port' => int (server port) 'appenv' => string (App environment) 'static' => boolean (true) (If it should server static files) 'logging' => boolean (false) (If it should log all requests) ...
$controller React\Socket\Connection Connection to ProcessManager, master process.
$errorLogger PHPPM\Debug\BufferingLogger
$inShutdown boolean
$lastSentFiles array | null Contains the cached version of last sent files, for performance reasons
$logFormat
$loop React\EventLoop\LibEventLoop | React\EventLoop\StreamSelectLoop
$server PHPPM\React\Server The HTTP Server.
$watchedFiles string[]

Public Methods

Method Description
__construct ( $bridgeName = null, $appBootstrap, array $config = [] )
commandBootstrap ( array $data, Connection $conn )
isDebug ( ) : boolean
isLogging ( ) : boolean
onRequest ( React\Http\Request $request, PHPPM\React\HttpResponse $response ) Handles incoming requests and transforms a $request into a $response by reference.
registerFile ( string $path ) Adds a file path to the watcher list queue which will be sent to the master process after each request.
run ( ) Connects to ProcessManager, master process.
shutdown ( ) Shuts down the event loop. This basically exits the process.

Protected Methods

Method Description
bootstrap ( string $appBootstrap, string $appenv, boolean $debug ) Bootstraps the actual application.
getBridge ( ) : PHPPM\Bridges\BridgeInterface
handleRequest ( React\Http\Request $request, PHPPM\React\HttpResponse $response ) Handle a redirected request from master.
isServingStatic ( ) : boolean
mimeContentType ( string $filename ) : string
prepareEnvironment ( React\Http\Request $request )
sendCurrentFiles ( ) Sends to the master a snapshot of current known php files, so it can track those files and restart slaves if necessary.
serveStatic ( React\Http\Request $request, PHPPM\React\HttpResponse $response ) : boolean
setupResponseLogging ( React\Http\Request $request, PHPPM\React\HttpResponse $response )

Method Details

__construct() public method

public __construct ( $bridgeName = null, $appBootstrap, array $config = [] )
$config array

bootstrap() protected method

Bootstraps the actual application.
protected bootstrap ( string $appBootstrap, string $appenv, boolean $debug )
$appBootstrap string
$appenv string
$debug boolean

commandBootstrap() public method

public commandBootstrap ( array $data, Connection $conn )
$data array
$conn React\Socket\Connection

getBridge() protected method

protected getBridge ( ) : PHPPM\Bridges\BridgeInterface
return PHPPM\Bridges\BridgeInterface

handleRequest() protected method

Handle a redirected request from master.
protected handleRequest ( React\Http\Request $request, PHPPM\React\HttpResponse $response )
$request React\Http\Request
$response PHPPM\React\HttpResponse

isDebug() public method

public isDebug ( ) : boolean
return boolean

isLogging() public method

public isLogging ( ) : boolean
return boolean

isServingStatic() protected method

protected isServingStatic ( ) : boolean
return boolean

mimeContentType() protected method

protected mimeContentType ( string $filename ) : string
$filename string
return string

onRequest() public method

Handles incoming requests and transforms a $request into a $response by reference.
public onRequest ( React\Http\Request $request, PHPPM\React\HttpResponse $response )
$request React\Http\Request
$response PHPPM\React\HttpResponse

prepareEnvironment() protected method

protected prepareEnvironment ( React\Http\Request $request )
$request React\Http\Request

registerFile() public method

Adds a file path to the watcher list queue which will be sent to the master process after each request.
public registerFile ( string $path )
$path string

run() public method

Connects to ProcessManager, master process.
public run ( )

sendCurrentFiles() protected method

Sends to the master a snapshot of current known php files, so it can track those files and restart slaves if necessary.
protected sendCurrentFiles ( )

serveStatic() protected method

protected serveStatic ( React\Http\Request $request, PHPPM\React\HttpResponse $response ) : boolean
$request React\Http\Request
$response PHPPM\React\HttpResponse
return boolean returns true if successfully served

setupResponseLogging() protected method

protected setupResponseLogging ( React\Http\Request $request, PHPPM\React\HttpResponse $response )
$request React\Http\Request
$response PHPPM\React\HttpResponse

shutdown() public method

Shuts down the event loop. This basically exits the process.
public shutdown ( )

Property Details

$appBootstrap protected property

protected string $appBootstrap
return string

$baseServer protected property

Copy of $_SERVER during bootstrap.
protected array $baseServer
return array

$bridge protected property

protected BridgeInterface,PHPPM\Bridges $bridge
return PHPPM\Bridges\BridgeInterface

$bridgeName protected property

protected string $bridgeName
return string

$config protected property

'port' => int (server port) 'appenv' => string (App environment) 'static' => boolean (true) (If it should server static files) 'logging' => boolean (false) (If it should log all requests) ...
protected array $config
return array

$controller protected property

Connection to ProcessManager, master process.
protected Connection,React\Socket $controller
return React\Socket\Connection

$errorLogger protected property

protected BufferingLogger,PHPPM\Debug $errorLogger
return PHPPM\Debug\BufferingLogger

$inShutdown protected property

protected bool $inShutdown
return boolean

$lastSentFiles protected property

Contains the cached version of last sent files, for performance reasons
protected array|null $lastSentFiles
return array | null

$logFormat protected property

protected $logFormat

$loop protected property

protected LibEventLoop,React\EventLoop|StreamSelectLoop,React\EventLoop $loop
return React\EventLoop\LibEventLoop | React\EventLoop\StreamSelectLoop

$server protected property

The HTTP Server.
protected Server,PHPPM\React $server
return PHPPM\React\Server

$slave public static property

Current instance, used by global functions.
public static ProcessSlave,phppm $slave
return ProcessSlave

$watchedFiles protected property

protected string[] $watchedFiles
return string[]