Skip to content

valkyrjaio/frankenphp

Valkyrja FrankenPHP

FrankenPHP persistent worker entry point for the Valkyrja Framework.

About

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.

PHP Version Require Latest Stable Version License Scrutinizer Coverage Status Psalm Shepherd Maintainability Rating

Build Status

Linting PHP Code Sniffer Build Status PHP CS Fixer Build Status
Coding Rules PHPArkitect Build Status Rector Build Status
Static Analysis PHPStan Build Status Psalm Build Status
Testing PHPUnit Build Status
## Installation
composer require valkyrja/frankenphp

Requires FrankenPHP running in worker mode.

Usage

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.

Customising Bootstrap

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);
    }
}

Worker Lifecycle

See the Valkyrja Framework README for a full explanation of the persistent worker lifecycle, the child container isolation model, and configuration options.

License

MIT

About

FrankenPHP persistent worker entry point for the Valkyrja PHP framework

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages