FrankenPHP
API reference › FrankenPHP › FrankenPHP
Runs the FrankenPHP worker loop for a Yii PSR bridge application.
Creates a PSR request from SAPI globals, emits the response, and finalizes the bridge lifecycle once per request. HEAD responses omit the body. See the README quick start for the entry script and required factory bindings.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Creates a new instance of the FrankenPHP class. | FrankenPHP |
run() | Runs the FrankenPHP worker loop for handling HTTP requests. | FrankenPHP |
Constants
Section titled “Constants”| Constant | Value | Description | Defined by |
|---|---|---|---|
DEFAULT_MAX_REQUESTS | 1000 | Default maximum number of requests to handle before stopping the worker loop. | FrankenPHP |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(yii2\extensions\psrbridge\http\Application $app, int|null $maxRequests = null)Creates a new instance of the FrankenPHP class.
Parameters
| Parameter | Type | Description |
|---|---|---|
$app | yii2\ | Application instance. |
$maxRequests | int| | Maximum number of requests to handle before stopping. If null, will try to read from $_ENV['MAX_REQUESTS'] or the process environment, otherwise defaults to ‘1000’. |
run()
Section titled “run() ”public function run(): intRuns the FrankenPHP worker loop for handling HTTP requests.
Returns
int: Exit code indicating the result of the worker loop execution (ServerExitCode::OK for success, ServerExitCode::REQUEST_LIMIT for request limit reached).
Throws
Throwable: if an exception occurs during request handling or response emission.