Mumbai, India

dqureshiumar@gmail.com

Add Database to a Laravel App on Heroku

Home  /  Add Database to a Laravel App on Heroku

Laravel Heroku

Add Database to Laravel on Heroku

by Umar Qureshi


Heroku supports PostGres Sql for Laravel App

  • Go to your Heroku App on the heroku website and locate the resources tab.


  • In the Add-Ons textbox select Heroku PostGres


  • dqureshiumar

  • Select a plan and Click on Provision


  • Thus we have created a Database on Heroku


  • Now, Under your Laravel App on your machine, open Terminal / Command Prompt and run :-
    heroku pg:credentials:url


    Database Local

  • You will get your database credentials.


  • Add our .env vars to our Laravel Application using command line statements
    EG : heroku config:add DB_CONNECTION=pgsql


  • Add all the database credentials using "heroku: config add" command



  • As we add our database credentials to our Heroku Application. Now we have to migrate our App to heroku server

    heroku run php artisan migrate



  • Now we have to create a new app on Heroku
    Use the command heroku create

    Heroku Create


  • Push your Laravel Webapp to heroku server using the command:
    git push heroku master



  • Cross check by running your Laravel Application that all your database queries are working fine for you.



  • Thus by following these steps we can Host our Laravel Webapp on Heroku. If any queries you can get back to dqureshiumar@gmail.com.
    Hope you liked it.
    Thank You.