Download the PHP package baldinof/roadrunner-bundle without Composer
On this page you can find all versions of the php package baldinof/roadrunner-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download baldinof/roadrunner-bundle
More information about baldinof/roadrunner-bundle
Files in baldinof/roadrunner-bundle
Package roadrunner-bundle
Short Description A RoadRunner worker as a Symfony Bundle
License MIT
Informations about the package roadrunner-bundle
Roadrunner Bundle
RoadRunner is a high-performance PHP application server, load-balancer, and process manager written in Golang.
This bundle provides a RoadRunner Worker integrated in Symfony, it's easily configurable and extendable.
Installation
Run the following command:
If you don't use Symfony Flex:
- register
Baldinof\RoadRunnerBundle\BaldinofRoadRunnerBundle
in your kernel - copy default RoadRunner configuration files:
cp vendor/baldinof/roadrunner-bundle/.rr.* .
Usage
- require the RoadRunner download utility:
composer require --dev spiral/roadrunner-cli
- get the RoadRunner binary:
vendor/bin/rr get --location bin/
- run RoadRunner with
bin/rr serve
orbin/rr serve -c .rr.dev.yaml
(watch mode) - visit your app at http://localhost:8080
Integrations
Depending on installed bundle & your configuration, this bundles add some integrations:
- Sentry: configure the request context (if the
SentryBundle
is installed) - Sessions: add the session cookie to the Symfony response (if
framework.sessions.enabled
config istrue
) - Doctrine Mongo Bundle: clear opened managers after each requests (if
DoctrineMongoDBBundle
is installed) - Doctrine ORM Bundle: clear opened managers and check connection is still usable after each requests (if
DoctrineBundle
is installed) - Blackfire: enable the probe when a profile is requested (if the
blackfire
extension is installed)
Even if it is not recommended, you can disable default integrations:
Middlewares
You can use middlewares to manipulate request & responses. Middlewares must implements Baldinof\RoadRunnerBundle\Http\MiddlewareInterface
.
Example configuration:
Be aware that
- middlewares are run outside of Symfony
Kernel::handle()
- the middleware stack is always resolved at worker start (can be a performance issue if your middleware initialization takes time)
Kernel reboots
The Symfony kernel and the dependency injection container are preserved between requests. If an exception is thrown during the request handling, the kernel is rebooted and a fresh container is used.
The goal is to prevent services to be in a non-recoverable state after an error.
To optimize your worker you can allow exceptions that does not put your app in an errored state:
If some of your services are stateful, you can implement
Symfony\Contracts\Service\ResetInterface
and your service will be resetted on each request.
If you are seeing issues and want to use a fresh container on each request you can use the always
reboot strategy:
If you are building long-running application and need to reboot it every XXX request to prevent memory leaks you can use max_jobs
reboot strategy:
You can combine reboot strategies:
Events
The following events are dispatched throughout the worker lifecycle:
Baldinof\RoadRunnerBundle\Event\WorkerStartEvent
: Dispatched right before the worker starts listening to requests.Baldinof\RoadRunnerBundle\Event\WorkerStopEvent
: Dispatched right before the worker closes.Baldinof\RoadRunnerBundle\Event\WorkerExceptionEvent
: Dispatched after encountering an uncaught exception during request handling.Baldinof\RoadRunnerBundle\Event\WorkerKernelRebootedEvent
: Dispatched after the symfony kernel was rebooted (see Kernel reboots).
Development mode
Copy the dev config file if it's not present: cp vendor/baldinof/roadrunner-bundle/.rr.dev.yaml .
Start RoadRunner with the dev config file:
Reference: https://roadrunner.dev/docs/beep-beep-reload
If you use the Symfony VarDumper, dumps will not be shown in the HTTP Response body. You can view dumps with bin/console server:dump
or in the profiler.
Metrics
Roadrunner can collect application metrics, and expose a prometheus endpoint.
Example configuration:
And configure RoadRunner:
Then simply inject Spiral\RoadRunner\MetricsInterface
to record metrics:
gRPC
gRPC support was added by the roadrunner-grpc plugin for RoadRunner 2 (https://github.com/spiral/roadrunner-grpc).
To configure Roadrunner for gRPC, refer to the configuration reference at https://roadrunner.dev/docs/beep-beep-grpc. Basic configuration example:
Once you have generated your PHP files from proto files, you just have to implement the service interfaces. GRPC services are registered automatically. Example service:
KV caching
Roadrunner has a KV (Key-Value) plugin that can be used to cache data between requests.
To use it, refer to the configuration reference at https://roadrunner.dev/docs/kv-overview.
This requires the spiral/roadrunner-kv
, spiral/goridge
and symfony/cache
composer dependencies. Basic configuration example:
Example configuration:
And configure RoadRunner:
An adapter service will now be created automatically for your storage with the name cache.adapter.roadrunner.kv_<YOUR_STORAGE_NAME>
.
Basic usage example:
Usage with Docker
All versions of roadrunner-bundle with dependencies
symfony/config Version ^6.0 || ^7.0
symfony/dependency-injection Version ^6.0 || ^7.0
symfony/http-kernel Version ^6.0 || ^7.0
symfony/yaml Version ^6.0 || ^7.0
spiral/roadrunner Version ^2023.1.0 || ^2024.1.0
spiral/roadrunner-worker Version ^3.0.0
spiral/goridge Version ^4.0
psr/log Version ^1.1 || ^2.0 || ^3.0
spiral/roadrunner-http Version ^3.0