Deploying your laravel project to heroku.

·

2 min read

Hey, this is a short documentation on how to deploy a laravel project on heroku.

First of all make sure the composer file is up-to-date and you can do this through

composer update.

To add the files to heroku, type out:

git add

and commit the files to the server through:

git commit -m initialcommit.

Before pushing your files to make sure you have created a new application on heroku and add the heroku remote provided. Moreover, if you cannot see it you can add the heroku remote by running ;

heroku git:remote -a yourappname

Then you can push your files through:

git push heroku main

We will need a database for the project. Postgres is preferred in this instance as it reliable, responsive and stable. Therefore, create the postgres sql database by running:

heroku addons:create heroku-postgresql:hobby-dev

Proceed to add the project configuration variables as so:

heroku config:set APP_NAME=yourappname

heroku config:set DB_DATABASE=yourdbname

heroku config:set DB_PORT=3306/your port in use

heroku config:add DB_CONNECTION=pgsql

heroku config:set APP_KEY=yourappkey

The app Key is found in the .env file. However, if you do not have an application key, you can generate one through :

php artisan --no-ansi key:generate --show

Then to finish it off, run the migrations on heroku by using the following commands:

heroku run php artisan migrate

heroku run php artisan db:seed

And voila!. ..there you have it. Your project is now on heroku🥳🙌.

Thanks for sticking around.