Magento 2 – Setup:di:compile Error Due to Duplicated Class of Data Migration Tool

fatal errormagento2setup-di-compile

I'm running into following fatal error when trying to execute the setup:di:compile command:

Fatal error: Cannot declare class Migration\Step\Version11410to2000Test, because the name is already in use in /var/www/html/magento/vendor/magento/data-migration-tool/tests/unit/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php on line 109

I tried to re-compile because I was getting an 404 on backend (triggered by magento, not apache websever).

Any help appreciated.

Edit:
It is a fresh Magento 2 install, except for adding the official (and correct) data-migration-tool.

Best Answer

change and give different class name for your controller class

this might be issue because your controller class name also used by some other controller

example shown in below url

https://stackoverflow.com/questions/708140/php-fatal-error-cannot-redeclare-class

And if this is the not case then

please delete di folder in var