{"id":14983960,"url":"https://github.com/baldinof/roadrunner-bundle","last_synced_at":"2025-04-13T01:55:45.126Z","repository":{"id":36473504,"uuid":"225610946","full_name":"Baldinof/roadrunner-bundle","owner":"Baldinof","description":"A RoadRunner worker integrated in your Symfony app","archived":false,"fork":false,"pushed_at":"2025-03-17T14:15:51.000Z","size":403,"stargazers_count":286,"open_issues_count":15,"forks_count":55,"subscribers_count":3,"default_branch":"3.x","last_synced_at":"2025-04-13T01:55:24.906Z","etag":null,"topics":["php","roadrunner","roadrunner-symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Baldinof.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["Baldinof"]}},"created_at":"2019-12-03T12:09:52.000Z","updated_at":"2025-03-17T20:10:23.000Z","dependencies_parsed_at":"2024-11-15T22:32:01.645Z","dependency_job_id":"b10ae3b9-13a7-4e9b-b933-dcdb314d7df3","html_url":"https://github.com/Baldinof/roadrunner-bundle","commit_stats":{"total_commits":210,"total_committers":25,"mean_commits":8.4,"dds":0.3761904761904762,"last_synced_commit":"025fab9012f63d9d3cf207d56bda380363654f0e"},"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Baldinof%2Froadrunner-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Baldinof%2Froadrunner-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Baldinof%2Froadrunner-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Baldinof%2Froadrunner-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Baldinof","download_url":"https://codeload.github.com/Baldinof/roadrunner-bundle/tar.gz/refs/heads/3.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654050,"owners_count":21140235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","roadrunner","roadrunner-symfony","symfony-bundle"],"created_at":"2024-09-24T14:08:14.590Z","updated_at":"2025-04-13T01:55:45.064Z","avatar_url":"https://github.com/Baldinof.png","language":"PHP","funding_links":["https://github.com/sponsors/Baldinof"],"categories":[],"sub_categories":[],"readme":"# Roadrunner Bundle\n\n[RoadRunner](https://roadrunner.dev/) is a high-performance PHP application server, load-balancer, and process manager written in Golang.\n\nThis bundle provides a RoadRunner Worker integrated in Symfony, it's easily configurable and extendable.\n\n## Installation\n\nRun the following command:\n\n```\ncomposer require baldinof/roadrunner-bundle\n```\n\nIf you don't use Symfony Flex:\n- register `Baldinof\\RoadRunnerBundle\\BaldinofRoadRunnerBundle` in your kernel\n- copy default RoadRunner configuration files: `cp vendor/baldinof/roadrunner-bundle/.rr.* .`\n\n## Usage\n\n- require the RoadRunner download utility: `composer require --dev spiral/roadrunner-cli`\n- get the RoadRunner binary: `vendor/bin/rr get --location bin/`\n- run RoadRunner with `bin/rr serve` or `bin/rr serve -c .rr.dev.yaml` (watch mode)\n- visit your app at http://localhost:8080\n\n## Integrations\n\nDepending on installed bundle \u0026 your configuration, this bundles add some integrations:\n\n- **Sentry**: configure the request context (if the [`SentryBundle`](https://github.com/getsentry/sentry-symfony) is installed)\n- **Sessions**: add the session cookie to the Symfony response (if `framework.sessions.enabled` config is `true`)\n- **Doctrine Mongo Bundle**: clear opened managers after each requests (if [`DoctrineMongoDBBundle`](https://github.com/doctrine/DoctrineMongoDBBundle) is installed)\n- **Doctrine ORM Bundle**: clear opened managers and check connection is still usable after each requests (if [`DoctrineBundle`](https://github.com/doctrine/DoctrineBundle) is installed)\n- **Blackfire**: enable the probe when a profile is requested (if the [`blackfire`](https://blackfire.io/) extension is installed)\n\nEven if it is not recommended, you can disable default integrations:\n\n```yaml\nbaldinof_road_runner:\n  default_integrations: false\n```\n\n## Middlewares\n\nYou can use middlewares to manipulate request \u0026 responses. Middlewares must implements [`Baldinof\\RoadRunnerBundle\\Http\\MiddlewareInterface`](./src/Http/MiddlewareInterface.php).\n\nExample configuration:\n\n```yaml\nbaldinof_road_runner:\n    middlewares:\n        - App\\Middleware\\YourMiddleware\n```\n\nBe aware that\n- middlewares are run outside of Symfony `Kernel::handle()`\n- the middleware stack is always resolved at worker start (can be a performance issue if your middleware initialization takes time)\n\n## Kernel reboots\n\nThe 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.\n\nThe goal is to prevent services to be in a non-recoverable state after an error.\n\nTo optimize your worker you can allow exceptions that does not put your app in an errored state:\n\n```yaml\n# config/packages/baldinof_road_runner.yaml\nbaldinof_road_runner:\n    kernel_reboot:\n      strategy: on_exception\n      allowed_exceptions:\n        - Symfony\\Component\\HttpKernel\\Exception\\HttpExceptionInterface\n        - Symfony\\Component\\Serializer\\Exception\\ExceptionInterface\n        - App\\Exception\\YourDomainException\n```\n\u003e If some of your services are stateful, you can implement `Symfony\\Contracts\\Service\\ResetInterface` and your service will be resetted on each request.\n\nIf you are seeing issues and want to use a fresh container on each request you can use the `always` reboot strategy:\n\n```yaml\n# config/packages/baldinof_road_runner.yaml\nbaldinof_road_runner:\n    kernel_reboot:\n      strategy: always\n```\n\nIf 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:\n\n```yaml\n# config/packages/baldinof_road_runner.yaml\nbaldinof_road_runner:\n    kernel_reboot:\n      strategy: max_jobs\n      max_jobs: 1000 # maximum number of request\n      max_jobs_dispersion: 0.2 # dispersion 20% used to prevent simultaneous reboot of all active workers (kernel will rebooted between 800 and 1000 requests) \n```\n\nYou can combine reboot strategies:\n\n\n```yaml\n# config/packages/baldinof_road_runner.yaml\nbaldinof_road_runner:\n    kernel_reboot:\n      strategy: [on_exception, max_jobs]\n      allowed_exceptions:\n        - Symfony\\Component\\HttpKernel\\Exception\\HttpExceptionInterface\n        - Symfony\\Component\\Serializer\\Exception\\ExceptionInterface\n        - App\\Exception\\YourDomainException\n      max_jobs: 1000\n      max_jobs_dispersion: 0.2\n```\n\n\n## Events\n\nThe following events are dispatched throughout the worker lifecycle:\n\n- `Baldinof\\RoadRunnerBundle\\Event\\WorkerStartEvent`: Dispatched right before the worker starts listening to requests.\n- `Baldinof\\RoadRunnerBundle\\Event\\WorkerStopEvent`: Dispatched right before the worker closes.\n- `Baldinof\\RoadRunnerBundle\\Event\\WorkerExceptionEvent`: Dispatched after encountering an uncaught exception during request handling.\n- `Baldinof\\RoadRunnerBundle\\Event\\WorkerKernelRebootedEvent`: Dispatched after the symfony kernel was rebooted (see Kernel reboots).\n\n## Development mode\n\nCopy the dev config file if it's not present: `cp vendor/baldinof/roadrunner-bundle/.rr.dev.yaml .`\n\nStart RoadRunner with the dev config file:\n\n```\nbin/rr serve -c .rr.dev.yaml\n```\n\nReference: https://roadrunner.dev/docs/beep-beep-reload\n\nIf 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.\n\n## Metrics\nRoadrunner can [collect application metrics](https://roadrunner.dev/docs/beep-beep-metrics), and expose a prometheus endpoint.\n\nExample configuration:\n\n```yaml\n# config/packages/baldinof_road_runner.yaml\nbaldinof_road_runner:\n  metrics:\n    enabled: true\n    collect:\n      user_login:\n        type: counter\n        help: \"Number of logged in user\"\n```\n\nAnd configure RoadRunner:\n\n```yaml\n# .rr.yaml\nrpc:\n  listen: \"tcp:127.0.0.1:6001\"\n\nmetrics:\n  address: \"0.0.0.0:9180\" # prometheus endpoint\n```\n\nThen simply inject `Spiral\\RoadRunner\\MetricsInterface` to record metrics:\n\n```php\nclass YouController\n{\n    public function index(MetricsInterface $metrics): Response\n    {\n        $metrics-\u003eadd('user_login', 1);\n\n        return new Response(\"...\");\n    }\n}\n```\n\n## gRPC\n\ngRPC support was added by the roadrunner-grpc plugin for RoadRunner 2 (https://github.com/spiral/roadrunner-grpc).\n\nTo configure Roadrunner for gRPC, refer to the configuration reference at https://roadrunner.dev/docs/beep-beep-grpc. Basic configuration example:\n\n```yaml\nserver:\n  command: \"php public/index.php\"\n  env:\n    APP_RUNTIME: Baldinof\\RoadRunnerBundle\\Runtime\\Runtime\n\ngrpc:\n  listen: \"tcp://:9001\"\n\n  proto:\n    - \"calculator.proto\"\n```\n\nOnce you have generated your PHP files from proto files, you just have to implement the service interfaces. GRPC services are registered automatically. Example service:\n\n```php\n\u003c?php\n\nnamespace App\\Grpc;\n\nuse Spiral\\RoadRunner\\GRPC;\nuse App\\Grpc\\Generated\\Calculator\\Sum;\nuse App\\Grpc\\Generated\\Calculator\\Result;\nuse App\\Grpc\\Generated\\Calculator\\CalculatorInterface;\n\nclass Calculator implements CalculatorInterface\n{\n    public function Sum(GRPC\\ContextInterface $ctx, Sum $in): Result\n    {\n        return (new Result())-\u003esetResult($in-\u003egetA() + $in-\u003egetB());\n    }\n}\n```\n\n## KV caching\n\nRoadrunner has a KV (Key-Value) plugin that can be used to cache data between requests. \n\nTo use it, refer to the configuration reference at https://roadrunner.dev/docs/kv-overview. \nThis requires the `spiral/roadrunner-kv`, `spiral/goridge` and `symfony/cache` composer dependencies. Basic configuration example:\n\nExample configuration:\n\n```yaml\n# config/packages/baldinof_road_runner.yaml\nbaldinof_road_runner:\n  kv:\n    storages:\n      - example\n```\n\nAnd configure RoadRunner:\n\n```yaml\n# .rr.yaml\nrpc:\n  listen: tcp://127.0.0.1:6001\n\nkv:\n  example:\n    driver: memory\n    config: { }\n```\n\nAn adapter service will now be created automatically for your storage with the name `cache.adapter.roadrunner.kv_\u003cYOUR_STORAGE_NAME\u003e`.\n\nBasic usage example:\n\n```yaml\n# config/packages/cache.yaml\nframework:\n  cache:\n    pools:\n      cache.example:\n        adapter: cache.adapter.roadrunner.kv_example\n```\n\n## Usage with Docker\n\n```Dockerfile\n# Dockerfile\nFROM php:8.1-alpine\n\nRUN apk add --no-cache linux-headers autoconf openssl-dev g++ make pcre-dev icu-dev zlib-dev libzip-dev \u0026\u0026 \\\n    docker-php-ext-install bcmath intl opcache zip sockets \u0026\u0026 \\\n    apk del --purge autoconf g++ make\n\nWORKDIR /usr/src/app\n\nCOPY --from=composer:latest /usr/bin/composer /usr/bin/composer\n\nCOPY composer.json composer.lock ./\n\nRUN composer install --no-dev --no-scripts --prefer-dist --no-progress --no-interaction\n\nRUN ./vendor/bin/rr get-binary --location /usr/local/bin\n\nCOPY . .\n\nENV APP_ENV=prod\n\nRUN composer dump-autoload --optimize \u0026\u0026 \\\n    composer check-platform-reqs \u0026\u0026 \\\n    php bin/console cache:warmup\n\nEXPOSE 8080\n\nCMD [\"rr\", \"serve\"]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaldinof%2Froadrunner-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaldinof%2Froadrunner-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaldinof%2Froadrunner-bundle/lists"}