{"id":14983601,"url":"https://github.com/spiral/roadrunner-bridge","last_synced_at":"2025-04-07T08:15:04.794Z","repository":{"id":37089592,"uuid":"447581540","full_name":"spiral/roadrunner-bridge","owner":"spiral","description":"🌉 RoadRunner bridge to Spiral Framework","archived":false,"fork":false,"pushed_at":"2025-03-30T18:08:14.000Z","size":2039,"stargazers_count":17,"open_issues_count":14,"forks_count":9,"subscribers_count":4,"default_branch":"4.x","last_synced_at":"2025-03-30T19:22:11.113Z","etag":null,"topics":["grpc","microservices","php","psr-16","psr-7","roadrunner","spiral-framework","tcp-client"],"latest_commit_sha":null,"homepage":"https://spiral.dev/docs/packages-roadrunner-bridge","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/spiral.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"spiral"}},"created_at":"2022-01-13T11:55:22.000Z","updated_at":"2025-03-05T17:52:13.000Z","dependencies_parsed_at":"2023-01-31T05:31:09.652Z","dependency_job_id":"08530708-a79e-4153-aa67-4b4d5fd4c8da","html_url":"https://github.com/spiral/roadrunner-bridge","commit_stats":{"total_commits":188,"total_committers":8,"mean_commits":23.5,"dds":0.574468085106383,"last_synced_commit":"948ef46290c535bdb320cdb5b1801bbcfd71047c"},"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spiral%2Froadrunner-bridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spiral%2Froadrunner-bridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spiral%2Froadrunner-bridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spiral%2Froadrunner-bridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spiral","download_url":"https://codeload.github.com/spiral/roadrunner-bridge/tar.gz/refs/heads/4.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247615377,"owners_count":20967184,"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":["grpc","microservices","php","psr-16","psr-7","roadrunner","spiral-framework","tcp-client"],"created_at":"2024-09-24T14:07:34.477Z","updated_at":"2025-04-07T08:15:04.776Z","avatar_url":"https://github.com/spiral.png","language":"PHP","funding_links":["https://github.com/sponsors/spiral"],"categories":[],"sub_categories":[],"readme":"# RoadRunner bridge to Spiral Framework\n\n[![PHP Version Require](https://poser.pugx.org/spiral/roadrunner-bridge/require/php)](https://packagist.org/packages/spiral/roadrunner-bridge)\n[![Latest Stable Version](https://poser.pugx.org/spiral/roadrunner-bridge/v/stable)](https://packagist.org/packages/spiral/roadrunner-bridge)\n[![phpunit](https://github.com/spiral/roadrunner-bridge/actions/workflows/phpunit.yml/badge.svg)](https://github.com/spiral/roadrunner-bridge/actions)\n[![psalm](https://github.com/spiral/roadrunner-bridge/actions/workflows/psalm.yml/badge.svg)](https://github.com/spiral/roadrunner-bridge/actions)\n[![Codecov](https://codecov.io/gh/spiral/roadrunner-bridge/branch/master/graph/badge.svg)](https://codecov.io/gh/spiral/roadrunner-bridge/)\n[![Total Downloads](https://poser.pugx.org/spiral/roadrunner-bridge/downloads)](https://packagist.org/packages/spiral/roadrunner-bridge)\n\u003ca href=\"https://discord.gg/8bZsjYhVVk\"\u003e\u003cimg src=\"https://img.shields.io/badge/discord-chat-magenta.svg\"\u003e\u003c/a\u003e\n\n## Requirements\n\nMake sure that your server is configured with following PHP version and extensions:\n\n- PHP 8.1+\n- Spiral Framework 3.14+\n\n## Installation\n\nTo install the package:\n\n```bash\ncomposer require spiral/roadrunner-bridge\n```\n\nAfter package install you need to add bootloaders from the package in your application on the top of the list.\n\n```php\nuse Spiral\\RoadRunnerBridge\\Bootloader as RoadRunnerBridge;\n\nprotected const LOAD = [\n    RoadRunnerBridge\\HttpBootloader::class, // Optional, if it needs to work with http plugin\n    RoadRunnerBridge\\QueueBootloader::class, // Optional, if it needs to work with jobs plugin\n    RoadRunnerBridge\\CacheBootloader::class, // Optional, if it needs to work with KV plugin\n    RoadRunnerBridge\\GRPCBootloader::class, // Optional, if it needs to work with GRPC plugin\n    RoadRunnerBridge\\CentrifugoBootloader::class, // Optional, if it needs to work with centrifugo server\n    RoadRunnerBridge\\TcpBootloader::class, // Optional, if it needs to work with TCP plugin\n    RoadRunnerBridge\\MetricsBootloader::class, // Optional, if it needs to work with metrics plugin\n    RoadRunnerBridge\\LoggerBootloader::class, // Optional, if it needs to work with app-logger plugin\n    RoadRunnerBridge\\LockBootloader::class, // Optional, if it needs to work with lock plugin\n    RoadRunnerBridge\\ScaffolderBootloader::class, // Optional, to generate Centrifugo handlers and TCP services via Scaffolder\n    RoadRunnerBridge\\CommandBootloader::class,\n    // ...\n];\n```\n\n## Usage\n\n- [Cache](https://spiral.dev/docs/basics-cache)\n- [Queue](https://spiral.dev/docs/queue-configuration)\n- [GRPC](https://spiral.dev/docs/grpc-configuration)\n- [Websockets](https://spiral.dev/docs/websockets-configuration)\n- [Logger](https://spiral.dev/docs/basics-logging/#roadrunner-handler)\n- [Metrics](https://spiral.dev/docs/advanced-prometheus-metrics)\n- [TCP](#tcp)\n    - [Configuration](#configuration-2)\n    - [Services](#services)\n\n### TCP\n\nRoadRunner includes TCP server and can be used to replace classic TCP setup with much greater performance and\nflexibility.\n\n#### Bootloader\n\nAdd `Spiral\\RoadRunnerBridge\\Bootloader\\TcpBootloader` to application bootloaders list:\n\n```php\nuse Spiral\\RoadRunnerBridge\\Bootloader as RoadRunnerBridge;\n\nprotected const LOAD = [\n    // ...\n    RoadRunnerBridge\\TcpBootloader::class,\n    // ...\n];\n```\n\nThis bootloader adds a dispatcher and necessary services for TCP to work.\nAlso, using the `addService` and `addInterceptors` methods can dynamically add services to TCP servers and configure\ninterceptors.\n\n#### Configuration\n\nConfigure `tcp` section in the RoadRunner `.rr.yaml` configuration file with needed TCP servers. Example:\n\n```yaml\ntcp:\n  servers:\n    smtp:\n      addr: tcp://127.0.0.1:22\n      delimiter: \"\\r\\n\" # by default\n    monolog:\n      addr: tcp://127.0.0.1:9913\n\n  pool:\n    num_workers: 2\n    max_jobs: 0\n    allocate_timeout: 60s\n    destroy_timeout: 60s\n```\n\nCreate configuration file `app/config/tcp.php`. In the configuration, it's required to specify the services that\nwill handle requests from a specific TCP server. Optionally, interceptors can be added for each specific server.\nWith the help there, can add some logic before handling the request in service. Configuration example:\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nreturn [\n    /**\n     * Services for each server.\n     */\n    'services' =\u003e [\n        'smtp' =\u003e SomeService::class,\n        'monolog' =\u003e OtherService::class\n    ],\n\n    /**\n     * Interceptors, this section is optional.\n     * @see https://spiral.dev/docs/cookbook-domain-core/2.8/en#core-interceptors\n     */\n    'interceptors' =\u003e [\n        // several interceptors\n        'smtp' =\u003e [\n            SomeInterceptor::class,\n            OtherInterceptor::class\n        ],\n        'monolog' =\u003e SomeInterceptor::class // one interceptor\n    ],\n\n    'debug' =\u003e env('TCP_DEBUG', false)\n];\n```\n\n#### Services\n\nA service must implement the interface `Spiral\\RoadRunnerBridge\\Tcp\\Service\\ServiceInterface` with one required\nmethod `handle`.\nAfter processing a request, the `handle` method must return the `Spiral\\RoadRunnerBridge\\Tcp\\Response\\ResponseInterface`\nobject\nwith result (`RespondMessage`, `CloseConnection`, `ContinueRead`).\n\nExample:\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Tcp\\Service;\n\nuse Spiral\\RoadRunner\\Tcp\\Request;\nuse Spiral\\RoadRunnerBridge\\Tcp\\Response\\RespondMessage;\nuse Spiral\\RoadRunnerBridge\\Tcp\\Response\\ResponseInterface;\nuse Spiral\\RoadRunnerBridge\\Tcp\\Service\\ServiceInterface;\n\nclass TestService implements ServiceInterface\n{\n    public function handle(Request $request): ResponseInterface\n    {\n        // some logic\n\n        return new RespondMessage('some message', true);\n    }\n}\n```\n\nThe service can be generated using the **Scaffolder** component. Make sure that bootloader\n`Spiral\\RoadRunnerBridge\\Bootloader\\ScaffolderBootloader` is added in your application and run:\n\n```bash\nphp app.php create:tcp-service Test\n```\n\nThis will generate service **TestService** in the folder **Endpoint/Tcp/Service/TestService.php**.\n\n\u003e **Note**\n\u003e Namespace (and generation path) can be configured.\n\u003e Read more about [Scaffolder component](https://spiral.dev/docs/basics-scaffolding).\n\n----\n\n\u003e **Note**\n\u003e Read more about RoadRunner configuration on official site https://roadrunner.dev.\n\n## License:\n\nMIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information. Maintained by [Spiral Scout](https://spiralscout.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspiral%2Froadrunner-bridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspiral%2Froadrunner-bridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspiral%2Froadrunner-bridge/lists"}