Documentation

GenericRuntime
in package
implements RuntimeInterface

A runtime to do bare-metal PHP without using superglobals.

It supports the following options:

  • "debug" toggles displaying errors and defaults to the "APP_DEBUG" environment variable;
  • "runtimes" maps types to a GenericRuntime implementation that knows how to deal with each of them;
  • "error_handler" defines the class to use to handle PHP errors;
  • "env_var_name" and "debug_var_name" define the name of the env vars that hold the Symfony env and the debug flag respectively.

The app-callable can declare arguments among either:

  • "array $context" to get a local array similar to $_SERVER;
  • "array $argv" to get the command line arguments when running on the CLI;
  • "array $request" to get a local array with keys "query", "body", "files" and "session", which map to $_GET, $_POST, $FILES and &$_SESSION respectively.

It should return a Closure():int|string|null or an instance of RunnerInterface.

In debug mode, the runtime registers a strict error handler that throws exceptions when a PHP warning/notice is raised.

Tags
author

Nicolas Grekas p@tchwork.com

Table of Contents

Interfaces

RuntimeInterface
Enables decoupling applications from global state.

Properties

$options  : mixed

Methods

__construct()  : mixed
getResolver()  : ResolverInterface
Returns a resolver that should compute the arguments of a callable.
getRunner()  : RunnerInterface
Returns a callable that knows how to run the passed object and that returns its exit status as int.
getArgument()  : mixed
register()  : self
getRuntime()  : self|null
resolveRuntime()  : self|null

Properties

Methods

__construct()

public __construct([array<string|int, mixed> $options = [] ]) : mixed
Parameters
$options : array<string|int, mixed> = []

getResolver()

Returns a resolver that should compute the arguments of a callable.

public getResolver(callable $callable[, ReflectionFunction $reflector = null ]) : ResolverInterface
Parameters
$callable : callable
$reflector : ReflectionFunction = null
Return values
ResolverInterface

getRunner()

Returns a callable that knows how to run the passed object and that returns its exit status as int.

public getRunner(object|null $application) : RunnerInterface
Parameters
$application : object|null
Return values
RunnerInterface

getArgument()

protected getArgument(ReflectionParameter $parameter, string|null $type) : mixed
Parameters
$parameter : ReflectionParameter
$type : string|null

register()

protected static register(self $runtime) : self
Parameters
$runtime : self
Return values
self

getRuntime()

private getRuntime(string $type) : self|null
Parameters
$type : string
Return values
self|null

resolveRuntime()

private resolveRuntime(string $class) : self|null
Parameters
$class : string
Return values
self|null

        
On this page

Search results