Home / Snippets / How to Seed Database After Deploying Laravel Application to Heroku
How to Seed Database After Deploying Laravel Application to Heroku cover

How to Seed Database After Deploying Laravel Application to Heroku

603

3 years ago

0 comments

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
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

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

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this