Deployment of the app can be a tedious task. Almost every cloud service provider has its own method to deploy an app on its platform. In this post, I’ll show you how to configure and deploy your existing Laravel app from local to Heroku. It’s quite easy.
Firstly the things you need:
- PHP and Laravel knowledge.
- Heroku user account.
- Heroku CLI.
- Git.
This tutorial assumes you already have your Laravel app created on your local server.
Configuring App for deployment
One: Initialize a git repository in your project working directory git init
Two: Run heroku create [your_app_name]
replace “your_app_name” with your preferred app name or leave it blank for Heroku to generate one for you.
Three: Go to your Heroku dashboard, in the Settings tab of your app, copy the git url for your project e.g https://git.heroku.com/yourappname.git
Four: From your cli, run git remote add heroku [your_app_git_url]
Five: Inside your project directory, create a new file called Procfile (with no extension) and add the following line: web: vendor/bin/heroku-php-apache2 public/
Six: Commit your changes (with git) and push to Heroku git push heroku master
Seven: Copy the APP_KEY from your .env file, then go to the Heroku dashboard for your app -> Settings -> Reveal Config Vars. Add new key pair values like APP_KEY : base64:…….
Step Eight: Now, navigate to the address for your app in your browser your_app_name.herokuapp.com
, your app should be up and running now.
Things to know
There are couple other things you might want to set up, based on the requirements of your app.
For your Laravel app to work properly, you need to set certain environment variables with Heroku (which is the equivalent of your local .env file).
There are two ways you can set env variables on Heroku:
- From the Heroku cmd, by running :
heroku config:set VAR_NAME=VAR_VALUE
- From the Heroku dashboard, in the Settings tab, click on Reveal Config Vars and set your variables there.

There is also a small python library that can help you set all your Heroku Config Vars from your .env file once. Check out the post here or check out the repo directly.
Friendly warning: the Heroku logs can be sometimes overwhelming, so you just have to take your time to sieve through and find what you’re looking for 😁. Check out more awesome pose on Borrowed Code.