web: vendor/bin/heroku-php-apache2 public/
heroku config:add APP_KEY="base64:enter_your_key" --app
or from Heroku interface by selecting the app and going to Settings -> Config Variables -> Reveal
'log' => 'errorlog'
Now the real gold nuggets I learned the hard way
The Heroku database is usually in Postgres. And there are a few differences from MySql: char fields, enum fields etc. So you better build the project directly on Postgres.
The database config file on Larvel should look like this:
'host' => getenv("DATABASE_URL") ? parse_url(getenv("DATABASE_URL"))["host"] : '',
'port' => getenv("DATABASE_URL") ? parse_url(getenv("DATABASE_URL"))["port"] : '',
'database' => getenv("DATABASE_URL") ? substr(parse_url(getenv("DATABASE_URL"))["path"], 1) : '',
'username' => getenv("DATABASE_URL") ? parse_url(getenv("DATABASE_URL"))["user"] : '',
'password' => getenv("DATABASE_URL") ? parse_url(getenv("DATABASE_URL"))["pass"] : '',
Heroku relies on composer.lock
to build the environment and pull the required packages. So if you need some libraries or extensions that are not built-in (e.g. gd library for images) and you cannot add them to your composer.json you can add them manually to the composer.lock
file. Here is a step by step guide. Also, here you can find a list of available extensions for Heroku.
Symlinks do not work. So don’t use the storage folder to save resources, better use a CDN.
You can add a free app in Heroku to test you project.
You can use iseed package to create seed files in order to populate your database.
You can run commands with Heroku CLI. For example, Artisan commands can be called like this:
heroku run "php artisan migrate" --app heroku-app-name
That’s all folks! I wish you easy deployment.
For more detailed info on how to get started with Laravel on Heroku you can go trough this article: Deploy Laravel app on Heroku
https://www.youtube.com/watch?v=639Pe0PpVLQ
#laravel #heroku #tutorial #devops