I want to create a BaseMigration
class like in this tutorial. I've saved it as app/database/migrations/BaseMigration.php
and extend it in my other migrations, but when I try to run my migrations via php artisan migrate
I get the following error:
PHP Fatal error: Class 'BaseMigration' not found in ...\app\database\migrations\2014_02_19_071702_create_users_table.php on line 6
Obviously it's having trouble autoloading it. How do I tell Laravel where to find it, or where should I move it to so that it can be found?
Usually
composer dump-autoload
Fixes those kind of errors, but sometimes it doesn't.
To understand if the problem is not in Laravel, but in autoloading (Composer or even PHP), take a look a the files in
vendor/composer/*
If your file is not using PSR-0, PSR-4 nor file autoloading, it should be
vendor/composer/autoload_classmap.php
If your file class is listed there, the problem is in your code, you're referencing it wrongly. In those files you'll find also the way you have to reference to it, for instance, if you have a namespace set on it, you'll have to use it the way it appears on those files.
If it's not listed, the problem is in the guy responsible for autoloading things: Composer (maybe even PHP) and you can refresh it to try to fix it:
rm -rf vendor
rm composer.lock
composer install