Download the PHP package magdv/roadrunner-symfony-bundle without Composer
On this page you can find all versions of the php package magdv/roadrunner-symfony-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download magdv/roadrunner-symfony-bundle
More information about magdv/roadrunner-symfony-bundle
Files in magdv/roadrunner-symfony-bundle
Package roadrunner-symfony-bundle
Short Description Roadrunner runtime for Symfony
License MIT
Informations about the package roadrunner-symfony-bundle
RoadRunner Runtime for Symfony
Yet another runtime for Symfony and RoadRunner.
Installation
Usage
Define the environment variable APP_RUNTIME
in .rr.yaml
and set up rpc
plugin:
.rr.yaml
Don't forget to add the RR_RPC
to your .env
:
Configuration
fluffy_discord_road_runner.yaml
Running behind a load balancer or a proxy
If you want to use REMOTE_ADDR
as trusted proxy, replace it with 0.0.0.0/0
instead
or else your trusted headers will not work.
Symfony is using the $_SERVER['REMOTE_ADDR']
to find out the proxy address,
but in the context of RoadRunner, $_SERVER
contains only environment
variables and the REMOTE_ADDS
is missing.
Response/file streaming
Build-in full support for Symfony's BinaryFileResponse
and StreamedJsonResponse
. The StreamedResponse
needs one little
change to be fully streamable - you have to change the callback
to a \Generator
, replacing all echo
with yield
. Look at the example:
Sessions
Currently, Symfony might sometimes struggle with sessions in worker mode, like loosing logged user or the opposite, leaking logged user session to another request due to missing globals (explained at the end).
Bundle introduces FluffyDiscord\RoadRunnerBundle\Session\WorkerSessionStorageFactory
, that handles native session correctly.
Register it manually if you happen to run into these issues, for example in framework.yaml
:
Sentry
Built in support for Sentry. Just install & configure it as you normally do.
Centrifugo (websockets)
To enable Centrifugo you need to add roadrunner-php/centrifugo
package.
Bundle is using Symfony's Event dispatcher. You can create event listener for any event extending FluffyDiscord\RoadRunnerBundle\Event\Centrifugo\CentrifugoEventInterface
:
ConnectEvent
required :)InvalidEvent
PublishEvent
RefreshEvent
RPCEvent
SubRefreshEvent
SubscribeEvent
Example usage:
Be aware that if you do not set any response, bundle will send DisconnectResponse
back by default.
Developing with Symfony and RoadRunner
- If possible, stop using lazy loading in your services, inject services immediately.
- It is no longer needed and might potentially bring issues to you like memory leaks.
- Do not use/create local class/array caches in your services. Try to make them stateless or if they cannot be, add ResetInterface to clean up before each request.
- Symfony forms might leak data across requests due to local caching it uses. Make sure your form
defaultOptions
are stateless. Do not store anything sensitive/important as it will be leaked in the following requests. - Simplify your
User
session serialization by taking advantage ofEquatableInterface
and custom de/serialization logic. This will prevent errors because of detached Doctrine entities and, as a side bonus, will speed up loading user from sessions.
Jobs
Надо реализовать интерфейс JobsRunner.
В методе run
обработать входящие задачи. Как? Это уже на ваше усмотрение.
Любой эксепшен вернет задачу в очередь.
Пример регистрации сервиса в DI services.yaml
Debugging (recommendations)
With RoadRunner you cannot simply dump and die, because nothing will be printed. I would like to introduce Buggregator to work around that. As a bonus it can also work as a mailtrap or testing Sentry locally
Credits
Inspiration taken from existing solutions like Baldinof's Bundle and Nyholm's Runtime
All versions of roadrunner-symfony-bundle with dependencies
ext-sockets Version *
nyholm/psr7 Version ^1.8
spiral/roadrunner Version ^v2024
symfony/dependency-injection Version ^7.1
symfony/http-kernel Version ^7.1
symfony/psr-http-message-bridge Version ^7.1
symfony/runtime Version ^7.1
symfony/framework-bundle Version ^7.1
spiral/roadrunner-worker Version ^v3
spiral/roadrunner-http Version ^v3
spiral/roadrunner-cli Version ^v2.6
spiral/roadrunner-jobs Version ^4.6
temporal/sdk Version ^2.11