After firing this command in command line php bin/magento setup:di:compile I am getting this error:

Cannot declare interface Magento\Framework\App\DeploymentConfig\Writer\FormatterInterface, because the name is already in use in /var/www/html/vendor/magento/framework/App/DeploymentConfig/Writer/FormatterInterface.php on line 9

Can you have a best solution for me?


  • Is there any custom extension? Dec 24, 2016 at 3:25
  • just try with remove var folder from root and run again. Dec 24, 2016 at 5:17

2 Answers 2


Please try to remove all the directories inside var/generation folder and then run following command :

php bin/magento cache:flush

After that run your command you will be succeed.

  • Thank for your idea!
    – Peter
    Jan 20, 2017 at 3:29
  • Most welcome :) Jan 9, 2019 at 11:09

Make sure that in your interface and also the interface that Magento says you are re-declaring, that you have declared the namespace at the top of both classes. This has happened to me before and that is usually the reason.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.