Support the ongoing development of Laravel.io →
Configuration Database Eloquent
Last updated 1 year ago.
0

Same problem. Installed Laravel this week.

Workflow:

dave@dave-VirtualBox ~/laravel $ php artisan migrate:make one
Created Migration: 2014_03_16_042521_one
Generating optimized class loader

dave@dave-VirtualBox ~/laravel $ php artisan migrate
Migrated: 2014_03_16_042521_one

dave@dave-VirtualBox ~/laravel $ php artisan migrate:rollback
PHP Fatal error:  Class 'One' not found in /home/dave/Documents/bitbucket/laravel-learn/laravel/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php on line 297
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'One' not found","file":"\/home\/dave\/Documents\/bitbucket\/laravel-learn\/laravel\/vendor\/laravel\/framework\/src\/Illuminate\/Database\/Migrations\/Migrator.php","line":297}}{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'One' not found","file":"\/home\/dave\/Documents\/bitbucket\/laravel-learn\/laravel\/vendor\/laravel\/framework\/src\/Illuminate\/Database\/Migrations\/Migrator.php","line":297}}
Last updated 1 year ago.
0

Run composer dumpautoload before migrate:rollback and see if that'll fix it.

Last updated 1 year ago.
0

php composer.phar dump-autoload indeed fixes this. But still I think it's a bug that 'migrate' does not depend on the autoload feature and apparently migrate:rollback does. Very fonfusing to new users, at least to me.

In Migrator::run(), the requireFiles() method is called (to include the migration files) before running the migrations. In Migrator::rollback(), requireFiles() is not called and loading the classes is dependent on the autoload feature. This should at least be more consistent.

Last updated 1 year ago.
0

Agree that this is also confusing because of the consistency. I never looked into the details so great to get an insight into what's happening.

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.