Laravel Octane: Running RoadRunner directly with .rr.yaml
Tags: laravel, go, roadrunner, php
Published: 2021-07-22 17:59:54

---
title: Laravel Octane: Running RoadRunner directly with .rr.yaml
published: true
date: 2021-07-12 12:02:46 UTC
tags: laravel,golang,roadrunner,php
canonical_url: 
---

### Laravel Octane: Running RoadRunner directly with .rr.yaml

![](https://cdn-images-1.medium.com/max/1024/0*VMcULZaRneophw-4)<figcaption>Photo by <a href="https://unsplash.com/@oktayyildiz?utm_source=medium&amp;utm_medium=referral">Oktay Yildiz</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption>

You may have tried [Laravel Octane](https://laravel.com/docs/8.x/octane) with [RoadRunner](https://roadrunner.dev/), a neat little PHP server written in Go. On the base install of Octane with RoadRunner you’ll have noticed a _.rr.yaml_ file is written to the project folder but is actually empty. Equally if you try to run the RoadRunner binary with ./rr then it’ll fail due to missing configuration values, instead you’re expected to run Octane via the php artisan octane:start command.

This works because the octane:start command runs the RoadRunner binary itself in a managed process while configuring the server via command line arguments with a few environment variables.

If we want to run the RoadRunner binary without the start command we have to either run it with the same command arguments or fill in the _.rr.yaml_ config ourselves. The values will need to be the following:

```
http:
  address: 127.0.0.1:8000
  pool:
    num_workers: 0
    max_jobs: 500
    supervisor:
      exec_ttl: 30s
  static:
    dir: public
  middleware: ["static"]

server:
  command: "php ./vendor/bin/roadrunner-worker"

  env:
    - APP_ENV: production
    - APP_BASE_PATH: "/path/to/your/laravel/protect"
    - LARAVEL_OCTANE: "1"

rpc:
  listen: tcp://127.0.0.1:6001

logs:
  mode: production
  level: debug
  output: stdout
  encoding: json
```

Not though that there are two parts in the config you might wish to alter. Namely the envs for the server command. To run the process you will have to hardcode the APP\_BASE\_PATH and the APP\_ENV via this file which can be a pain.

Another thing to note is that by default Laravel Octane installs RoadRunner with the _.rr.yaml_ config file in the project’s _.gitignore_ file so you’ll have to set this up on each machine unless you decide to change this though currently I think it best to add the config per device you use as the base path will change potentially per machine.

With the modified _.rr.yaml_ file in place you can now run the ./rr serve command and have a running server without using artisan.

### Why might you want to run RoadRunner directly?

It might become a bit of a question of why it’s possibly better to use the road runner binary directly and the answer is that for most people it isn’t. For myself I have intentions of building more into roadrunner going forward, including running the server in a docker container. Because of this I actually need RoadRunner to output it’s logging information directly into stdout rather than using the octane:start command which obfuscates this logging information into its own format that makes viewing request statuses quite simple.

Hopefully this will be of use to some of you out there who are looking to dive a bit deeper into the depths of RoadRunner and how to customise it beyond the basic setup. Should you want to learn more about the options available to you in the RoadRunner config you can read about them in the [docs](https://roadrunner.dev/docs/intro-config).

I’m Peter Fox, a software developer in the UK who works with Laravel among other things. Thank you for reading my article, I’ve got several more on both medium and dev.to. If you want to know more about me, head over to [https://www.peterfox.me](https://www.peterfox.me/). Also feel free to follow me @[SlyFireFox](https://twitter.com/SlyFireFox) on twitter for more Laravel tips and tutorials in the future.