10

My magento store is throwing this error:

Fatal error: Cannot instantiate interface Magento\Framework\View\Design\Theme\ResolverInterface in /Library/WebServer/Documents/magento/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php on line 73

I don't know why it started to appear. I made no new module installation. The store was working fine.

I've check file permissions and I see no issue there. Also delete the /var/ dir and, I think, all folders/files where created.

[EDIT] The preference is defined vendor/magento/magento2-base/app/etc/di.xml

<preference for="Magento\Framework\View\Design\Theme\ResolverInterface" type="Magento\Theme\Model\Theme\Resolver" /> 
  • 1
    i hope in ur custom module or code your trying to use Magento\Framework\View\Design\Theme\ResolverInterface in constructor or object manager – Pradeep Kumar Nov 24 '15 at 4:28
  • @PradeepKumar No. I'm not. – Filipe Sá Nov 24 '15 at 14:19
  • 2
    clear your cache and the contents of var/generation. – Marius Nov 24 '15 at 14:23
  • @Marius as stated in the question, I've already removed the /var/* folder completely. – Filipe Sá Nov 24 '15 at 14:28
  • Sorry. I missed that line. – Marius Nov 24 '15 at 14:44

10 Answers 10

21

If you use redis, run:


redis-cli flushall



If you also use an environment like ansible (lxc - server), you'll need to do that command in container. Plus I did the following:

  • Clear var/generation
  • Clear var/cache
  • Enable Magento modules: bin/magento module:enable --all
  • Compile DI bin/magento setup:di:compile
  • 1
    there were so many misleading solutions out there and this worked right away – user44406 Jan 8 '19 at 8:15
  • 2
    Enable Magento modules: bin/magento module:enable --all - Worked for me – Agnes Feb 18 '19 at 12:40
  • NO! It`s not good practice! bin/magento module:enable --all is like chmod -R 777 :( – Kārlis Millers Dec 5 '19 at 9:22
6

I had this error and it was solved by clearing the var folder and then running setup:upgrade. If this doesn't solve it then look for errors in di.xml files

  • worked for me, specifically var/cache – Joshua Soileau Jul 25 '16 at 17:46
  • Thanks redis-cli flushall worked for me. – Sarjan Gautam Oct 30 '19 at 1:17
2

This worked for me :

 sudo apt-get install php-intl

 sudo service apache2 reload
2

Run following command and check.

rm -rf generated

rm -rf var/*

Worked for me.

1

In my case, I had to remove a module and I simply deleted the files of the module without following proper methods and then this error was on screen everywhere. After searching much I ended up to replace the files of the module back to same directory and deleted all required folders from var and ran the following commands.

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy

and all was fixed. I then followed proper ways to remove the module. Hope this saves someones time. :-)

1

Clear the cache rm -rf var/cache

If redis enabled, clear redis db using command line:

$> redis-cli
$> flushall
0
php bin/magento c:c
php bin/magento setup:di:compile

will fix your issue

0

Dump composer autoload files:

$ composer dumpautoload

Then:

bin/magento setup:upgrade
bin/magento setup:di:compile
0

Same problem I was faced when updating the Magento version 2.3.3. so I replace the app/etc/di.xml file content help with below path. https://github.com/magento/magento2/blob/ddf42caaf25311f10b23b95a92746f99943e045e/app/etc/di.xml#L212

My issue is resolved now

0

This error is created when you try creating (new) an object (class) that is in fact and interface. This normally happens when you have not overridden the interface for a class in the di.xml file. Or have overridden the in the di.xml in the adminhtml directory and are trying to use the interface in the frontend.

interface MyInterface{
   pubic function getVariable(): int
}

class MyClass 
implements MyInterface{

   protected $variable;

   pubic function getVariable(){
      return $this->variable;
   }
}

$variable = new MyInterface();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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