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/php-laravel
The gerardbalaoro/php-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.
The buildpack will replace the existing .env file using variables from your Heroku Config Vars.
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:
- APP_NAME
- APP_ENV
- APP_DEBUG
- APP_URL
For database configuration variables:
- DB_CONN (Database Driver)
- DB_HOST
- DB_PORT
- DB_USER
- DB_PASS
- DB_NAME (Database Name)
For email configuration variables:
- MAIL_DRIVER
- MAIL_HOST
- MAIL_USER
- MAIL_PASS
- MAIL_PORT
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
heroku config:set LARAVEL_ENV_VARS=BROADCAST_DRIVER=log
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.
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
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