Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rtacadena's avatar

How to seed database after deploying the Laravel app on Heroku?

I successfully deployed a laravel app on Heroku but when I run 'heroku run php artisan db:seed' I got this error:

[Symfony\Component\Debug\Exception\FatalThrowableError] Fatal error: Class 'Faker\Factory' not found

Does any one of you get the error deploying on heroku?

I use cleardb add ons.

When I run 'heroku run php artisan migrate' all works fine only the heroku run php artisan db:seed' has error.

Is there a problem on my composer not loading the Faker library? or permission on vendor folder?

I will appreciate any help. Thanks.

0 likes
15 replies
willvincent's avatar

faker is a dev requirement, so by default it won't be installed in a production environment.

If you run composer install --dev it should install the require-dev items from your composer.json.

So.. heroku run composer install --dev then you should be able to heroku run php artisan db:seed

2 likes
rtacadena's avatar

C:\xampp\htdocs\laravel-exam3>heroku run composer install --dev Running composer install --dev on laraexam... up, run.4477 You are using the deprecated option "dev". Dev packages are installed by default now. Loading composer repositories with package information Installing dependencies (including require-dev) from lock file

  • Installing fzaninotto/faker (v1.6.0) Downloading: 100%

  • Installing hamcrest/hamcrest-php (v1.2.2) Downloading: 100%

  • Installing mockery/mockery (0.9.4) Downloading: 100%

  • Installing phpdocumentor/reflection-docblock (2.0.4) Downloading: 100%

It seems the Faker was updated but the error still persists.

willvincent's avatar

must be a namespace issue then, or your autoloader is wrong/etc.. I'm not a fan of heroku for this reason, too difficult to really understand what's going on on their end.

martinbean's avatar

@rtacadena Did you check the namespace as suggested? As it seems the library was installed from your log snippet.

naveenpeterj's avatar

I too had the same problem. Even after you run composer install (or composer update) some packages are not installed(which includes fzaninotto/faker ) . You can see this if you run the command "heroku run 'cd vendor && ls -la'". The solution is:

  1. run "heroku run bash". This creates a one-off-dyno in your heroku app.

2.run "composer update". now if you check vendor folder you can see fzaninotto/faker package installed.

3.now run "php artisan db:seed". Your database will be seeded.

6 likes
Lina's avatar

I have an error with faker:

Seeding: UsersTableSeeder

[Symfony\Component\Debug\Exception\FatalThrowableError] Class 'Faker\Factory' not found

Please or to participate in this conversation.