18

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" /> 
5
  • 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
  • 3
    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

12 Answers 12

54

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 (or generated/* in newer versions)
  • Clear var/cache
  • Check if the module generating the error is enabled and enable it (bin/magento module:enagle Some_Module) or Enable all Magento modules: bin/magento module:enable --all
  • Compile DI bin/magento setup:di:compile
9
  • 1
    there were so many misleading solutions out there and this worked right away – user44406 Jan 8 '19 at 8:15
  • 5
    Enable Magento modules: bin/magento module:enable --all - Worked for me – Agnes Feb 18 '19 at 12:40
  • 2
    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
  • Worked like a charm. Was using a redis container. using flushall resolved the issue – Umar Yousaf Oct 22 '20 at 11:40
  • flushing the redis cache solved it, even though that project has not even redis configured. I use redis for another shop though. – Black Dec 2 '20 at 14:14
9

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

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

Run following command and check.

rm -rf generated

rm -rf var/*

Worked for me.

2

This worked for me :

 sudo apt-get install php-intl

 sudo service apache2 reload
2

Clear the cache rm -rf var/cache

If redis enabled, clear redis db using command line:

$> redis-cli
$> flushall
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

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

1

This error could also because of enabling or disabling the modules directly in app/etc/config.php especially when to enable or disable core Magento modules. The best thing to do in such case would be to clear your cache, flush redis cache, restart varnish & php-fpm. And it works.

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

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();
0

The problem might be related to the file app/etc/di.xml.

In my case I accidentially overwrote it with the file of another project. After replacing it, it worked again!

These two lines were missing in my broken di.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    ...
    <preference for="Magento\Framework\Interception\ConfigLoaderInterface" type="Magento\Framework\Interception\PluginListGenerator" />
    <preference for="Magento\Framework\Interception\ConfigWriterInterface" type="Magento\Framework\Interception\PluginListGenerator" />

There was also a difference in the PluginList Class:

Broken di.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
...
    <type name="Magento\Framework\Interception\PluginList\PluginList">
        <arguments>
            <argument name="cache" xsi:type="object">Magento\Framework\App\Cache\Type\Config</argument>
            <argument name="reader" xsi:type="object">Magento\Framework\ObjectManager\Config\Reader\Dom\Proxy</argument>
            <argument name="cacheId" xsi:type="string">plugin-list</argument>
            <argument name="scopePriorityScheme" xsi:type="array">
                <item name="first" xsi:type="string">global</item>
            </argument>
        </arguments>
    </type>
 ...

Working di.xml:

Please make sure that it looks like this:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
...
    <type name="Magento\Framework\Interception\PluginList\PluginList">
        <arguments>
            <argument name="cache" xsi:type="object">Magento\Framework\App\Cache\Type\Config</argument>
            <argument name="reader" xsi:type="object">Magento\Framework\ObjectManager\Config\Reader\Dom\Proxy</argument>
            <argument name="cacheId" xsi:type="string">plugin-list</argument>
            <argument name="scopePriorityScheme" xsi:type="array">
                <item name="primary" xsi:type="string">primary</item>
                <item name="first" xsi:type="string">global</item>
            </argument>
        </arguments>
    </type>
    <type name="Magento\Framework\Interception\PluginListGenerator">
        <arguments>
            <argument name="reader" xsi:type="object">Magento\Framework\ObjectManager\Config\Reader\Dom\Proxy</argument>
            <argument name="logger" xsi:type="object">\Psr\Log\LoggerInterface\Proxy</argument>
            <argument name="scopePriorityScheme" xsi:type="array">
                <item name="primary" xsi:type="string">primary</item>
                <item name="first" xsi:type="string">global</item>
            </argument>
        </arguments>
    </type>
...

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.