framework: php artisan migrate: Cannot redeclare class CreateUsersTable
When i try to:
php artisan migrate
I get:
PHP Fatal error: Cannot redeclare class CreateUsersTable in /database/migrations/2014_10_12_000000_create_users_table.php on line 36
[Symfony\Component\Debug\Exception\FatalErrorException]
Cannot redeclare class CreateUsersTable
I already did: sudo composer.phar dump-autoload
Laravel Framework version 5.0.31 I suspect this error is due to permission errors on the autoload.php file
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 24 (1 by maintainers)
Please ask on the forums.
That is happen because this class declared at least 2 times, the first one in laravel/database/migrations/ , and the another one is declared in a non-explicit way by composer as you can see in (/vendor/composer/autoload_classmap.php).
In order to handle this issue, first you have to run : $ composer install
and not that the composer will generate warning look like this:
Warning: Ambiguous class resolution, “CreateUsersTable” was found in both “/var/www/html/laravel1/database/migrations/2015_09_28_082513_create_users_table.php” and “/var/www/html/laravel2/database/migrations/2014_10_12_000000_create_users_table.php”, the first will be used.
This explains why the laravel migration return this collision warning.
@NguyenBaoTran check the
database/migrationsdirectory, find out if there is any files containing the same part in file name,XXXX_XX_XX_XXXXXX_create_users_table.php.If there is, keep only one file that is valid to you.