Successfully reported this slideshow.

Deploy Laravel on Heroku



1 of 24
1 of 24

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

Deploy Laravel on Heroku

  1. 1. Deploy Laravel on Heroku
  2. 2. About Me Eric Van Johnson PHP Developer, Architect and an Organizer of SDPHP ● Twitter: @shocm ● IRC: @shocm
  3. 3. Laravel 101 We start with a standard Laravel deployment And then a cd into our project directory
  4. 4. Unlock you lock We want to remove ‘composer.lock’ from .gitignore
  5. 5. Heroku Procfile You can configure Heroku server by leveraging a ‘Procfile’. We will use this to update our doc root to point to our /public directory
  6. 6. Git’er Done Next we initiate our Git repo and commit some changes.
  7. 7. Use the --force Your Laravel application will complain if it doesn’t have a log file and it’s unable to create one once deployed to Heroku. So we will create it now and force add it to the repo
  8. 8. Commit to your choices in life Now we can do a git commit of our project.
  9. 9. Heroku Time You’ll need to have a Heroku account and have the Heroku Toolbelt installed and configured. Great place to get started: We’ll flash forward past this
  10. 10. Spinning up Heroku We create our Heroku instance and deploy our repo to it.
  11. 11. Check out your awesome app At this time we have our basic Laravel Application deployed and can view it.
  12. 12. Add layers to the Application Let’s update our routes, add a controller and add a view like a normal application. app/routes.php app/controllers/HelloController.php app/views/hello/index.blade.php
  13. 13. Check out your awesome app Commit, push to Heroku and go to the new route.
  14. 14. Adding PostgreSQL to your app Why PostgreSQL and not MySQL? ● Heroku doesn’t have ‘native’ MySQL support ● In Heroku world, PostgreSQL is a first class citizen. ● There is a solution that allows you to add a MySQL to your Heroku app called ‘ClearDB’ addon if you really want it. ● Since we are using Laravel and Eloquent, we don’t actual care what our datastore is.
  15. 15. Adding PostgreSQL (Part 2) Adding PostgreSQL is as simple as running a command.
  16. 16. A peek at the config Let’s see what was assigned to us
  17. 17. Modify start.php We are going to edit bootstrap/start.php to better detect environments
  18. 18. Create Heroku Configurations Next we create configuration files specifically for Heroku at the following path
  19. 19. Configure Database app/config/heroku/database.php Also be sure to update app/config/database.php and define PostgeSQL ● 'default' => 'pgsql', Commit and push
  20. 20. Create APP_ENV Variable Remember we are detecting which environment we are in, in start.php using the variable ‘APP_ENV’. We will need to create and add that variable to our Heroku environment.
  21. 21. Create a migration Now we create a migration using the normal Laravel commands. Commit and Push
  22. 22. Run migration After we push our new migration we need to run the migration in the Heroku environment.
  23. 23. Check migration was successful
  24. 24. Enjoy Life START CODING!