Laravel Application Deploy in Heroku Cloud Platform

Laravel Application deploy
Spread the love

Laravel Application Deploy tutorial, I will show you how to upload your application in Heroku. Heroku is a cloud platform as a service supporting several programming languages.  I will show you everything step by step. So here we go.

What is Heroku?

Heroku is a cloud platform as a service supporting several programming languages. One of the first cloud platforms, Heroku has been in development since June 2007, when it supported only the Ruby programming language, but now supports Java, Node.js, Scala, Clojure, Python, PHP, and Go.

Well, First you have to create an account in Heroku. To do that go to the Heroku official documentation. After creating an account then you have to install Heroku CLI. To download Heroku CLI you have to go to this website

Well, after installing Heroku CLI you can see the version of Heroku which you installed before. Run this code in your terminal. heroku --version

Laravel Application Deploy
Heroku CLI

Well, now you have to login into Heroku using the terminal. To do that run this command heroku login, then give your credentials.

Read More : How to install Docker on ubuntu 20.04 with Docker Compose

Well, now go to your laravel project and create a Procfile. To do that run this command in your terminal touch Procfile or you can create it manually. Well, inside this procfile you have to define what our application runs on dynos. Dynos are basically just a little container within Heroku. Paste this below code in your procfile.

web: vendor/bin/heroku-php-apache2 public/

Now you have to push your application in Heroku. run below code step by step.

git init

git add .

git commit -m"inital release"

Well, now you have to create a Heroku app. To create a Heroku app run this command in your terminal.

heroku create

It will create a random app, you can see it in your Heroku dashboard. Well, now you have to push the application to the Heroku server.

git push heroku

It will take a couple of times to upload all files. Well, after uploading all files then you have to add environment variables to run your application. You can add environment variables are two ways. One is manually another one using Heroku CLI.

To add manually go to heroku dashboard and open your app. then go to the settings then add config vars like this.

Well, you can also add env variables using the commands like this.

heroku config:add key=value
// ex : heroku config:add APP_DEBUG = false

Well, now you have to choose a database. to do that go to your app’s dashboard and go to the Resources tab and search and add-ons.

Search Heroku Postgres and select this database. Well, now you have to add your database credentials. To get database credentials run this command in the terminal.

heroku pg:credentials:url

then you can get credentials like this.

Well, add all environment variables like before. After add, all credentials run this command heroku run php artisan migrate

Finally, go to the app’s dashboard and open your app. Hope this tutorial will help you.

Spread the love

About Anisur Rahman Shahin

Hello. My name is Shahin. I'm a tech enthusiast guy. Personally, I’m an Optimistic and always in hurry kinda person. I'm a freelance web developer. I am working at Zakir Soft as Laravel Developer. My Portfolio website:

View all posts by Anisur Rahman Shahin →

Leave a Reply

Your email address will not be published.