Posts Learn Components Snippets Categories Tags Tools new About
/

How to Seed Database After Deploying Laravel Application to Heroku

Learn how to seed database after deploying Laravel app to production on Heroku

Created on Jul 13, 2021

260 views

If you are using "fzaninotto/faker" library to generate fake data in Laravel, then you know how handy it's to have in your application for testing. When you have an application that you deploy to Heroku, you might face some issue that you can't run "php artisan db:seed" on Heroku.
php artisan db:seed

The cause of this is because Heroku only installs the dependencies that's in "require" so what you have to do is move "fzaninotto/faker" to "require-dev" and update the composer file for the latest composer.lock before pushing the latest changes to Heroku.

Full Steps by Steps Guide
  1. Move "fzaninotto/faker" from "require-dev" to "require"
  2. Update composer with "composer update" (this will update composer.lock file)
  3. Push the changes to GitHub / Heroku then deploy it to production
  4. Run the database seed command

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

)