FrankenPHP persistent worker entry point for the Valkyrja Framework.
This repository provides the FrankenPHP persistent worker entry point for the Valkyrja Framework.
Bootstraps the application once at startup, then dispatches every incoming request to an isolated child container — so request state never bleeds between requests.
| Linting |
|
|
| Coding Rules |
|
|
| Static Analysis |
|
|
| Testing |
|
composer require valkyrja/frankenphpRequires FrankenPHP running in worker mode.
use Valkyrja\Application\Data\HttpConfig;
use Valkyrja\FrankenPhp\FrankenPhpHttp;
FrankenPhpHttp::run(new HttpConfig(
dir: __DIR__ . '/..',
));run() bootstraps the application once when the worker process starts, then
enters the FrankenPHP request loop. Each request is handled in an isolated child
container so state never bleeds between requests.
Override bootstrapParentServices() to force-resolve services that are
expensive to create and safe to share across requests:
use Valkyrja\Application\Kernel\Contract\ApplicationContract;
use Valkyrja\FrankenPhp\FrankenPhpHttp;
use Valkyrja\Http\Routing\Collection\Contract\CollectionContract;
class App extends FrankenPhpHttp
{
protected static function bootstrapParentServices(ApplicationContract $app): void
{
$container = $app->getContainer();
$container->getSingleton(CollectionContract::class);
$container->getSingleton(MyExpensiveSharedService::class);
}
}See the Valkyrja Framework README for a full explanation of the persistent worker lifecycle, the child container isolation model, and configuration options.
MIT
