DEV Community

Deploy a Laravel 5 app to Heroku

Connor Leech on August 29, 2017

Heroku is an awesome platform originally built on top of AWS and currently owned by Salesforce. Laravel is a powerful PHP web framework for build...
Collapse
 
mostueck profile image
Moritz Stückler

My deployment seems to work finde, until php artisan is running some script which is trying to connect to the database (which doesn't exist yet, because I haven't run migrations yet). Any idea what that happens?

...

  • Installing graham-campbell/manager (v4.0.0): Downloading (100%)
  • Installing vinkla/hashids (4.0.0): Downloading (100%) Generating optimized autoload files > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php artisan package:discover

In Connection.php line 664:

SQLSTATE[HY000] [2002] Connection refused (SQL: select * from questions)

...

Collapse
 
connor11528 profile image
Connor Leech

you need to have a production database connected to heroku

Collapse
 
anmollohana profile image
anmollohana

I have deployed a few applications on the AWS server with Devrims Laravel Hosting Services, which was an excellent experience.
Deploying the application on Heroku could be difficult for me, but thank you for sharing this information and making it easy for all who have not deployed their applications on Heroku before.

Collapse
 
azazqadir profile image
Muhammad Azaz Qadir

I have never used Heroku. Is it like Forge, where you have to pay separate invoice to provider and the platform. Or like Cloudways (cloudways.com/en/laravel-hosting.php ), where you only have to pay the invoice to the platform.

Collapse
 
connor11528 profile image
Connor Leech

It’s based on traffic and cpu. Most of the time it’s free. If you need special features the hobby plan is $7/month heroku.com/pricing

Collapse
 
zaratedev profile image
Jonathan Zarate

Thanks! awesome tutorial. :D

Collapse
 
antoine profile image
Antoine Gagnon • Edited

Great tutorial ! Seems like everything worked for me :) Now onto your Vue tutorial ;)

Collapse
 
khalifa profile image
khalifa

Great tutorial
Huge thing missing though:

heroku run composer install

Collapse
 
connor11528 profile image
Connor Leech

There's another helpful tutorial here that uses more steps through the Heroku UI: mikateach.com/setting-up-laravel-5...

Collapse
 
youdevs profile image
Carlos Hernández

Thank you bro <3

Collapse
 
its_phronesis profile image
Joey K

I'm getting an error! That the host, user, and pass indexes of $url are undefined indexes. What am I missing?

Collapse
 
connor11528 profile image
Connor Leech

Do you have CLEARDB_DATABASE_URL as an environment variable set in heroku? You can check by typing herou config devcenter.heroku.com/articles/conf...

Collapse
 
roniemeque profile image
Ronie

man I just had to deploy an Laravel app for a client to see how the project was going in like a EXTREMELY BIG HURRY. You saved my life, for real. God bless you.

Collapse
 
r2luna profile image
Rafael Lunardelli

I'm trying to deploy my laravel app but I'm having problem with the npm run production command. Can you helps us with that?

Collapse
 
connor11528 profile image
Connor Leech

maybe. What's the error?