1. Create the Procfile and add it to your repo. The content should look like this:
web: vendor/bin/heroku-php-apache2 public/
  1. Set up the ENV variables. You can do this using Heroku cli and entering this command line:
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

  1. Update the log setting to errorlog. Put this in the app config file:
'log' => 'errorlog'

Now the real gold nuggets I learned the hard way

  1. 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.

  2. 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"] : '',
  1. 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.

  2. Symlinks do not work. So don’t use the storage folder to save resources, better use a CDN.

  3. You can add a free app in Heroku to test you project.

  4. You can use iseed package to create seed files in order to populate your database.

  5. 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

Steps to swiftly deploy your Laravel app on Heroku
4.55 GEEK