Laravel, PHP, Software Development

Start Up Laravel Application by Running Roadrunner

Are you doubting the potential performance of the PHP application you’ve been building with Laravel Framework? As an interpreted language, PHP is slow. Factor in the apparent out-of-the-box slowness that we could attribute to the framework; your application could be slower. Also, PHP JIT and Opcache may not be enough. If you’ve heard about Laravel Octane, it enables us to serve our Laravel application using high-powered application servers. This post shows how to serve a Laravel application using Roadrunner on a local machine.

Laravel Application plus Roadrunner on a local machine

To emphasize the limitation of such a setup, this post ONLY shows the use of a development environment on a local machine. Any attempt to replicate it in a production setup will require more than this post offers.

We will use Laravel 9, Windows 10, Composer, PHP 8, and Roadrunner.

Roadrunner and a Laravel Application To Use

First, we need a Laravel application. It could be a new or an existing application that we can run locally via the artisan command. Next, we install Laravel Octane using the following command.

Among other things, this command creates script files in the vendor\bin folder. These include the following.

  • roadrunner-worker
  • roadrunner-worker.bat
  • swoole-server
  • swoole-server.bat

We will reference one of these files in a roadrunner configuration file (.yaml).

Then, we run another command to install support for the roadrunner and serve the Laravel application using roadrunner.

Next, we download roadrunner.

Laravel Roadrunner

Then, go to the releases section and download the correct binary files. For this post, we use binaries for Windows.

Laravel Roadrunner

 

Next, unzip the file and copy the file rr.exe  to the root folder of a Laravel project.

Roadrunner .rr.yaml Configuration File

Next, we create a .rr.yaml file for roadrunner and place it in the same folder as the file rr.exe. Notice that we may need to change the APP_BASED_PATH to point to the Laravel root folder.

Startup Roadrunner

Finally, we can start roadrunner and serve the Laravel application using the command rr serve.

laravel Roadrunner

Loading

Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.


You Might Also Like