PHPackages                             spiral/roadrunner-bridge - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. spiral/roadrunner-bridge

ActiveLibrary

spiral/roadrunner-bridge
========================

RoadRunner integration package

v3.8.0(11mo ago)631.6M↓35.4%11[7 issues](https://github.com/spiral/roadrunner-bridge/issues)[2 PRs](https://github.com/spiral/roadrunner-bridge/pulls)10MITPHPPHP &gt;=8.1CI passing

Since Feb 3Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/spiral/roadrunner-bridge)[ Packagist](https://packagist.org/packages/spiral/roadrunner-bridge)[ Docs](https://spiral.dev)[ GitHub Sponsors](https://github.com/sponsors/roadrunner-server)[ RSS](/packages/spiral-roadrunner-bridge/feed)WikiDiscussions 4.x Synced 1mo ago

READMEChangelog (10)Dependencies (19)Versions (47)Used By (10)

RoadRunner bridge to Spiral Framework
=====================================

[](#roadrunner-bridge-to-spiral-framework)

[![PHP Version Require](https://camo.githubusercontent.com/1a541cad3617be5bc397f3f1cdee0e5ab3c5703f641f8cad60dc717145ae4dca/68747470733a2f2f706f7365722e707567782e6f72672f73706972616c2f726f616472756e6e65722d6272696467652f726571756972652f706870)](https://packagist.org/packages/spiral/roadrunner-bridge)[![Latest Stable Version](https://camo.githubusercontent.com/39a6eef9f2c9cd9d0f52711397f76b54c7b7a7c91b01e7456da1ee0ae90070ea/68747470733a2f2f706f7365722e707567782e6f72672f73706972616c2f726f616472756e6e65722d6272696467652f762f737461626c65)](https://packagist.org/packages/spiral/roadrunner-bridge)[![phpunit](https://github.com/spiral/roadrunner-bridge/actions/workflows/phpunit.yml/badge.svg)](https://github.com/spiral/roadrunner-bridge/actions)[![psalm](https://github.com/spiral/roadrunner-bridge/actions/workflows/psalm.yml/badge.svg)](https://github.com/spiral/roadrunner-bridge/actions)[![Codecov](https://camo.githubusercontent.com/ff2b5fc24fcd0cdef72f0a1b1812b0c54f93757dc4cbafe2a2887b5fae322716/68747470733a2f2f636f6465636f762e696f2f67682f73706972616c2f726f616472756e6e65722d6272696467652f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/spiral/roadrunner-bridge/)[![Total Downloads](https://camo.githubusercontent.com/809dee4f60998a5cbc0312800455e01a78e400039ae6c181258f4e18859e56b4/68747470733a2f2f706f7365722e707567782e6f72672f73706972616c2f726f616472756e6e65722d6272696467652f646f776e6c6f616473)](https://packagist.org/packages/spiral/roadrunner-bridge)[![](https://camo.githubusercontent.com/4442b73a11753b80fdd7b442ddbfaf8383902c8b9ffa66ed1718e8c62e102f2e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646973636f72642d636861742d6d6167656e74612e737667)](https://discord.gg/8bZsjYhVVk)

Requirements
------------

[](#requirements)

Make sure that your server is configured with following PHP version and extensions:

- PHP 8.1+
- Spiral Framework 3.14+
- Extension `protobuf` (recommended)

Installation
------------

[](#installation)

To install the package:

```
composer require spiral/roadrunner-bridge
```

After package install you need to add bootloaders from the package in your application on the top of the list.

```
use Spiral\RoadRunnerBridge\Bootloader as RoadRunnerBridge;

protected const LOAD = [
    RoadRunnerBridge\HttpBootloader::class, // Optional, if it needs to work with http plugin
    RoadRunnerBridge\QueueBootloader::class, // Optional, if it needs to work with jobs plugin
    RoadRunnerBridge\CacheBootloader::class, // Optional, if it needs to work with KV plugin
    RoadRunnerBridge\GRPCBootloader::class, // Optional, if it needs to work with GRPC plugin
    RoadRunnerBridge\CentrifugoBootloader::class, // Optional, if it needs to work with centrifugo server
    RoadRunnerBridge\TcpBootloader::class, // Optional, if it needs to work with TCP plugin
    RoadRunnerBridge\MetricsBootloader::class, // Optional, if it needs to work with metrics plugin
    RoadRunnerBridge\LoggerBootloader::class, // Optional, if it needs to work with app-logger plugin
    RoadRunnerBridge\LockBootloader::class, // Optional, if it needs to work with lock plugin
    RoadRunnerBridge\ScaffolderBootloader::class, // Optional, to generate Centrifugo handlers and TCP services via Scaffolder
    RoadRunnerBridge\CommandBootloader::class,
    // ...
];
```

Usage
-----

[](#usage)

- [Cache](https://spiral.dev/docs/basics-cache)
- [Queue](https://spiral.dev/docs/queue-configuration)
- [GRPC](https://spiral.dev/docs/grpc-configuration)
- [Websockets](https://spiral.dev/docs/websockets-configuration)
- [Logger](https://spiral.dev/docs/basics-logging/#roadrunner-handler)
- [Metrics](https://spiral.dev/docs/advanced-prometheus-metrics)
- [TCP](#tcp)
    - [Configuration](#configuration-2)
    - [Services](#services)

### TCP

[](#tcp)

RoadRunner includes TCP server and can be used to replace classic TCP setup with much greater performance and flexibility.

#### Bootloader

[](#bootloader)

Add `Spiral\RoadRunnerBridge\Bootloader\TcpBootloader` to application bootloaders list:

```
use Spiral\RoadRunnerBridge\Bootloader as RoadRunnerBridge;

protected const LOAD = [
    // ...
    RoadRunnerBridge\TcpBootloader::class,
    // ...
];
```

This bootloader adds a dispatcher and necessary services for TCP to work. Also, using the `addService` and `addInterceptors` methods can dynamically add services to TCP servers and configure interceptors.

#### Configuration

[](#configuration)

Configure `tcp` section in the RoadRunner `.rr.yaml` configuration file with needed TCP servers. Example:

```
tcp:
  servers:
    smtp:
      addr: tcp://127.0.0.1:22
      delimiter: "\r\n" # by default
    monolog:
      addr: tcp://127.0.0.1:9913

  pool:
    num_workers: 2
    max_jobs: 0
    allocate_timeout: 60s
    destroy_timeout: 60s
```

Create configuration file `app/config/tcp.php`. In the configuration, it's required to specify the services that will handle requests from a specific TCP server. Optionally, interceptors can be added for each specific server. With the help there, can add some logic before handling the request in service. Configuration example:

```
