Posts Learn Components new Snippets new Categories Tags About Device Beast sponsor

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


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

Snippets by

PostSrc poster


Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.


PostSrc Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that are right for your project.

View Components

Other Code Snippets