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
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.
Thanks Wesamazmy! Your answer really helped me.
thanks, that happened to me too.
Hi guys, I'm a newbie. I have a problem like you. Could you explain more clearly about the solution, please?
@NguyenBaoTran check the database/migrations
directory, 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.
ok, the problem was solved. Thank you so much!
@Wesamazmy how to run composer please ?
nice solution
awesome... :+1:
it works great on create table, but if I update table schema twice, is there a better way to solve it?
@oniceriver create new migration to update schema
Thanks, this is nice solution for me!!
composer install
did the trick for me. Thanks @Wesamazmy
Had this problem because I had two models with the same class name (filenames were different). An oversight from someone working in the project beforehand.
run
composer dump-autoload
and also helped me to solve the problem
Warning: Ambiguous class resolution, "CreateAuthEmailTable" was found in both "/home/vagrant/XLO/XLO/database/migrations/2017_09_06_060751_create_authPhone_table.php" and "/home/vagrant/XLO/XLO/database/migrations/2017_09_06_060814_create_authEmail_table.php", the first will be used.
thanx Bro
Hello Friends,
I am getting same error
PHP Fatal error: Cannot declare class CreateActivityLogTable, because the name is already in use in C:\xampp\htdocs\projecthttpdocs\vendor\EmergeInc\BusinessPartners\database\migrations\2017_11_02_072823_create_activity_log_table.php on line 44
Please anyone help me to solve this error.
@Digital4design just delete this file C:\xampp\htdocs\project\httpdocs\vendor\EmergeInc\BusinessPartners\database\migrations\2017_11_02_072823_create_activity_log_table.php
then execute command again
All those solutions fix the problem once it is thre, but how do you recommend to avoid this issue in the first place? I have a coworker that causes this very often and I don't know how he got in that situation in the first place... does artisan make migration
allow for this to happen? should my coworker have seen this error before he commited the migration? what are the best practices?
It saved my day. Thanks!
I think there is a problem installing the composer
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 installand 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.
Thanks a lot.............
check in the database/migrations if they are to files with the same table name and delete one 馃槈
Most helpful comment
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.