by pinodex

GitHub Readme.md

Heroku Buildpack: Laravel

Laravel Heroku Buildpack

Forked from the Official Heroku PHP Buildpack with added support for Laravel Applications.


You'll need to use at least an empty composer.json in your application.

echo '{}' > composer.json
git add composer.json
git commit -m "add composer.json for PHP app detection"

If you also have files from other frameworks or languages that could trigger another buildpack to detect your application as one of its own, e.g. a package.json which might cause your code to be detected as a Node.js application even if it is a PHP application, then you need to manually set your application to use this buildpack:

heroku buildpacks:set gerardbalaoro/laravel

The gerardbalaoro/laravel buildpack from the Heroku Registry represents the latest stable version of the buildpack. If you'd like to use the code from this Github repository, you can set your buildpack to the Github URL:

heroku buildpacks:set https://github.com/gerardbalaoro/heroku-buildpack-laravel.git

Please refer to Dev Center for further usage instructions.

Environment Variables

The buildpack will replace the existing .env file using variables from your Heroku Config Vars.

Generic Variables

The buildpack will recognize the APP_, DB_, and MAIL_ variables set in Heroku.

# Adds APP_NAME="Laravel App" to .env file
heroku config:set APP_NAME="Laravel App"

The following are the supported application variables:


For database configuration variables:

  • DB_CONN (Database Driver)
  • DB_NAME (Database Name)

For email configuration variables:


Additional Variables

For environment variables not metioned above, define them in the config variable LARAVEL_ENV_VARS and it will automatically be appended to the .env file.

# Adds BROADCAST_DRIVER=log to .env file

Unfortunately, the heroku config:set command only works for single-line strings, for multiple environment variables, set them at your Heroku application dashboard under the settings tab.

Set Laravel Environment Variables

Laravel Commands

The buildpack automatically runs the following artisan commands:

php artisan key:generate
php artisan view:clear

To run additional commands, set assign them to the config variable LARAVEL_COMMANDS

# Executes php artisan migrate and php artisan db:seed
heroku config:set LARAVEL_COMMANDS=php artisan migrate && php artisan db:seed

HTTP Basic Authentication

This will generate an .htpasswd file based on the config variable HT_AUTH

# Executes htpasswd -cb .htpasswd {username} {password}
heroku config:set HT_AUTH={username} {password}

It will also append the authentication code in public/.htaccess

AuthType Basic
AuthName "Restricted Access"
AuthUserFile /app/.htpasswd
Require valid-user