Runway

Laravel

The following describes the steps necessary to deploy a Laravel app. If you want to skip the project setup, head over to our Github repository to find the code.

Project setup

$ composer create-project laravel/laravel example-laravel-app
Creating a "laravel/laravel" project at "./example-laravel-app"
Info from https://repo.packagist.org: #StandWithUkraine
Installing laravel/laravel (v9.3.6)
  - Installing laravel/laravel (v9.3.6): Extracting archive
Created project in /Users/till/Documents/workspaces/hostwithquantum/example-laravel-app
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Lock file operations: 105 installs, 0 updates, 0 removals
  - Locking brick/math (0.10.2)
  - Locking dflydev/dot-access-data (v3.0.1)
  - Locking doctrine/inflector (2.0.4)
  - Locking doctrine/instantiator (1.4.1)
  - Locking doctrine/lexer (1.2.3)
  - Locking dragonmantank/cron-expression (v3.3.1)
  - Locking egulias/email-validator (3.2.1)
  - Locking fakerphp/faker (v1.20.0)
  - Locking filp/whoops (2.14.5)

For Laravel to work, it requires the OpenSSL PHP extension. Unfortunately, this extension is missing in composer.json but we can add it ourselves and this serves as a good example how to add all the dependencies of your application so our build service assembles everything you need.

$ composer require ext-openssl
Using version * for ext-openssl
Info from https://repo.packagist.org: #StandWithUkraine
./composer.json has been updated
Running composer update ext-openssl
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Writing lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating optimized autoload files
...

OpenSSL

In the previous section we mentioned that adding an extension to the composer.json should make the builder assemble all required dependencies. But unfortunately there is an open bug in one of the buildpacks regarding the OpenSSL PHP-extension specifically. So in order to make it work, or for example to load non-standard extension, here is how.

The buildpack process adds a directory .php.ini.d which is inside your project to the PHP_INI_SCAN_DIR. Use that to add additional PHP configuration, such as loading other extensions.

$ mkdir .php.ini.d/
$ echo "extension=openssl.so" >> .php.ini.d/custom.ini

Deployment

Create an application:

$ runway app create
INFO    created app "comfortable-planet"             
create app comfortable-planet: done
next steps:  
* commit your changes  
* runway app deploy  
* runway open

… and set configuration. Laravel wants an a 32-character long application secret. Generate it like so:

$ cat /dev/urandom | env LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
9i8ttROYLyfXrDJTkRrAqkYnMmtg3gJi

… and add it

$ runway app config set APP_KEY=9i8ttROYLyfXrDJTkRrAqkYnMmtg3gJi
INFO    configuring app "comfortable-planet"         
configure app comfortable-planet: done
Name    Value                 
APP_KEY 9i8ttROYLyfXrDJTkRrAqkYnMmtg3gJi
$ runway app config set APP_DEBUG=true
INFO    configuring app "comfortable-planet"         
configure app comfortable-planet: done
Name      Value                 
APP_KEY   9i8ttROYLyfXrDJTkRrAqkYnMmtg3gJi
APP_DEBUG true
$ runway app config set LOG_CHANNEL=stderr
INFO    configuring app "comfortable-planet"         
configure app comfortable-planet: done
Name        Value                            
APP_KEY     9i8ttROYLyfXrDJTkRrAqkYnMmtg3gJi 
APP_DEBUG   true                             
LOG_CHANNEL stderr

Please note: this is the minimum to deploy the example application.