You may have tried Laravel Octane with RoadRunner, 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:
middleware: [ "static" ]
command: "php ./vendor/bin/roadrunner-worker"
- APP_ENV: production
- APP_BASE_PATH: "/path/to/your/laravel/protect"
- LARAVEL_OCTANE: "1"
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.
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. Also feel free to follow me @SlyFireFox on twitter for more Laravel tips and tutorials in the future.