PHPackages                             roadrunner-php/laravel-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. [HTTP &amp; Networking](/categories/http)
4. /
5. roadrunner-php/laravel-bridge

ActiveLibrary[HTTP &amp; Networking](/categories/http)

roadrunner-php/laravel-bridge
=============================

Laravel integration for RoadRunner with support for HTTP, Jobs, gRPC, and Temporal plugins - going beyond Octane's capabilities

6.3.0(7mo ago)49143.2k—2.6%38[4 issues](https://github.com/roadrunner-php/laravel-bridge/issues)1MITPHPPHP ^8.2CI passing

Since May 22Pushed 7mo ago14 watchersCompare

[ Source](https://github.com/roadrunner-php/laravel-bridge)[ Packagist](https://packagist.org/packages/roadrunner-php/laravel-bridge)[ GitHub Sponsors](https://github.com/sponsors/roadrunner-server)[ RSS](/packages/roadrunner-php-laravel-bridge/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (17)Versions (39)Used By (1)

 [![logo](https://camo.githubusercontent.com/f110b54b2589b4c79e86fddceb977c26a4517a32483b42add752727f7832022a/68747470733a2f2f6873746f2e6f72672f776562742f786c2f70722f38392f786c707238393163797639757833676d3764747a776a73655f35612e706e67)](https://camo.githubusercontent.com/f110b54b2589b4c79e86fddceb977c26a4517a32483b42add752727f7832022a/68747470733a2f2f6873746f2e6f72672f776562742f786c2f70722f38392f786c707238393163797639757833676d3764747a776a73655f35612e706e67)

[RoadRunner](https://github.com/roadrunner-server/roadrunner) ⇆ [Laravel](https://laravel.com) bridge
=====================================================================================================

[](#roadrunner--laravel-bridge)

[![Version](https://camo.githubusercontent.com/57ccde8a92e76067b142f8cd727df0bd35e5dc5792807637acf6fd377bdf8371/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f616472756e6e65722d7068702f6c61726176656c2d6272696467652e7376673f6d61784167653d313830)](https://packagist.org/packages/roadrunner-php/laravel-bridge)[![Version](https://camo.githubusercontent.com/7110a03ff1859d10343b30472c9974ac71065ca434c5dd86129b2918302c478c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f726f616472756e6e65722d7068702f6c61726176656c2d6272696467652e7376673f6c6f6e6743616368653d74727565)](https://packagist.org/packages/roadrunner-php/laravel-bridge)[![License](https://camo.githubusercontent.com/70e844ad7488ed6178a164e8ac461b0a6f87afec951eff548a24f9dcd5bdee19/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f726f616472756e6e65722d7068702f6c61726176656c2d6272696467652e7376673f6d61784167653d323536)](https://github.com/roadrunner-php/laravel-bridge/blob/master/LICENSE)

Easy way for connecting [RoadRunner](https://github.com/roadrunner-server/roadrunner) and [Laravel](https://laravel.com) applications (community integration).

Why Use This Package?
---------------------

[](#why-use-this-package)

This package provides complete Laravel integration with RoadRunner, offering:

- Support for HTTP and other RoadRunner plugins like gRPC, Queue, KeyValue, and more.
- [Temporal](https://temporal.io/) integration
- Full RoadRunner configuration control
- PSR-3 compatible logging with RoadRunner integration

[![RoadRunner](https://private-user-images.githubusercontent.com/773481/441208808-609d2e29-b6af-478b-b350-1d27b77ed6fb.jpg?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQzNTU5ODQsIm5iZiI6MTc3NDM1NTY4NCwicGF0aCI6Ii83NzM0ODEvNDQxMjA4ODA4LTYwOWQyZTI5LWI2YWYtNDc4Yi1iMzUwLTFkMjdiNzdlZDZmYi5qcGc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMzI0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDMyNFQxMjM0NDRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04ZTAyMjE0NzIyMThmZmVmMjNmZmJjMzc4MDdlODNlODEwMWM0ZDYxMTQwMDM0MjY1YzczNzhmOThiOWZlYTkwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.HCIq20kQemwFmEIqGQ2q1FUDZU64WUwcIRLsQTRc0NQ)](https://private-user-images.githubusercontent.com/773481/441208808-609d2e29-b6af-478b-b350-1d27b77ed6fb.jpg?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQzNTU5ODQsIm5iZiI6MTc3NDM1NTY4NCwicGF0aCI6Ii83NzM0ODEvNDQxMjA4ODA4LTYwOWQyZTI5LWI2YWYtNDc4Yi1iMzUwLTFkMjdiNzdlZDZmYi5qcGc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMzI0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDMyNFQxMjM0NDRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04ZTAyMjE0NzIyMThmZmVmMjNmZmJjMzc4MDdlODNlODEwMWM0ZDYxMTQwMDM0MjY1YzczNzhmOThiOWZlYTkwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.HCIq20kQemwFmEIqGQ2q1FUDZU64WUwcIRLsQTRc0NQ)

Tip

[There is an article](https://butschster.medium.com/roadrunner-an-underrated-powerhouse-for-php-applications-46410b0abc) that explains all the RoadRunner plugins.

Table of Contents
-----------------

[](#table-of-contents)

- [Get Started](#get-started)
    - [Installation](#installation)
    - [Configuration](#configuration)
    - [Starting the Server](#starting-the-server)
- [How It Works](#how-it-works)
- [Supported Plugins](#supported-plugins)
    - [HTTP Plugin](#http-plugin)
    - [Jobs (Queue) Plugin](#jobs-queue-plugin)
    - [gRPC Plugin](#grpc-plugin)
    - [gRPC Client](#grpc-client)
    - [Temporal](#temporal)
- [Logging](#logging)
- [Custom Workers](#custom-workers)
- [Support](#support)
- [License](#license)

Get Started
-----------

[](#get-started)

### Installation

[](#installation)

First, install the Laravel Bridge package via Composer:

```
composer require roadrunner-php/laravel-bridge
```

Publish the configuration file:

```
php artisan vendor:publish --provider='Spiral\RoadRunnerLaravel\ServiceProvider' --tag=config
```

Download and install RoadRunner binary using DLoad:

```
./vendor/bin/dload get rr
```

### Configuration

[](#configuration)

Create a `.rr.yaml` configuration file in your project root:

```
version: '3'
rpc:
  listen: 'tcp://127.0.0.1:6001'

server:
  command: 'php vendor/bin/rr-worker start'

http:
  address: 0.0.0.0:8080
  middleware: [ "static", "headers", "gzip" ]
  pool:
    #max_jobs: 64 # feel free to change this
    supervisor:
      exec_ttl: 60s
  headers:
    response:
      X-Powered-By: "RoadRunner"
  static:
    dir: "public"
    forbid: [ ".php" ]
```

### Starting the Server

[](#starting-the-server)

Start the RoadRunner server with:

```
./rr serve
```

How It Works
------------

[](#how-it-works)

RoadRunner creates a worker pool by executing the command specified in the server configuration:

```
server:
  command: 'php vendor/bin/rr-worker start'
```

When RoadRunner creates a worker pool for a specific plugin, it sets the `RR_MODE` environment variable to indicate which plugin is being used. The Laravel Bridge checks this variable to determine which Worker class should handle the request based on your configuration.

The selected worker then listens for requests from the RoadRunner server and handles them using the [Octane](https://laravel.com/docs/12.x/octane) worker, which clears the application state after each task (request, command, etc.).

Supported Plugins
-----------------

[](#supported-plugins)

### HTTP Plugin

[](#http-plugin)

The HTTP plugin enables serving HTTP requests with your Laravel application through RoadRunner.

#### Configuration

[](#configuration-1)

Ensure your `.rr.yaml` has the HTTP section configured:

```
http:
  address: 0.0.0.0:8080
  middleware: [ "static", "headers", "gzip" ]
  pool:
    max_jobs: 64
  static:
    dir: "public"
    forbid: [ ".php" ]
```

Tip

Read more about the HTTP plugin in the [RoadRunner documentation](https://docs.roadrunner.dev/docs/http/http).

### Jobs (Queue) Plugin

[](#jobs-queue-plugin)

The Queue plugin allows you to use RoadRunner as a queue driver for Laravel without additional services like Redis or a database.

#### Configuration

[](#configuration-2)

First, add the Queue Service Provider in `config/app.php`:

```
'providers' => [
    // ... other providers
    Spiral\RoadRunnerLaravel\Queue\QueueServiceProvider::class,
],
```

Then, configure a new connection in `config/queue.php`:

```
'connections' => [
    // ... other connections
   'roadrunner' => [
      'driver' => 'roadrunner',
      'queue' => env('RR_QUEUE', 'default'),
      'retry_after' => (int) env('RR_QUEUE_RETRY_AFTER', 90),
      'after_commit' => false,
   ],
],
```

Update your `.rr.yaml` file to include the Jobs section:

```
jobs:
  pool:
    num_workers: 4
  pipelines:
    default:
      driver: memory
      config: { }
```

Set the `QUEUE_CONNECTION` environment variable in your `.env` file:

```
QUEUE_CONNECTION=roadrunner
```

That's it! You can now dispatch jobs to the RoadRunner queue without any additional services like Redis or Database.

Tip

Read more about the Jobs plugin in the [RoadRunner documentation](https://docs.roadrunner.dev/docs/queues-and-jobs/overview-queues).

### gRPC Plugin

[](#grpc-plugin)

The gRPC plugin enables serving gRPC services with your Laravel application.

#### Configuration

[](#configuration-3)

Configure gRPC in your `.rr.yaml`:

```
grpc:
  listen: 'tcp://0.0.0.0:9001'
  proto:
    - "proto/service.proto"
```

Then, add your gRPC services to `config/roadrunner.php`:

```
return [
    // ... other configuration
    'grpc' => [
        'services' => [
            \App\GRPC\EchoServiceInterface::class => \App\GRPC\EchoService::class,

            // Service with specific interceptors
            \App\GRPC\UserServiceInterface::class => [
                'service' => \App\GRPC\UserService::class,
                'interceptors' => [
                    \App\GRPC\Interceptors\ValidationInterceptor::class,
                    \App\GRPC\Interceptors\CacheInterceptor::class,
                ],
            ],
        ]
    ],
];
```

#### gRPC Server Interceptors

[](#grpc-server-interceptors)

Create your interceptor by implementing `Spiral\Interceptors\InterceptorInterface`:

```
