<p>Make sure you have the correct namespace in your <code>modules/exifreturn/src/ExifReturn.php</code> class. From what you show, you should have:</p>
<pre><code>namespace modules\exifreturn;
</code></pre>
<p>Right at the top, after <code>&lt;?php</code>. With that in place, run <code>composer dumpautoload</code>.</p>

CC BY-SA 4.0
2021-01-19T23:15:20.157Z
Thanks Oli, `composer dumpautoload` did it! :)
Tyssen
CC BY-SA 4.0
2021-01-19T07:50:59.493Z
2021-01-19T07:50:59.493Z
Oli
<p>I have a site with a custom module that was working fine until just recently but I tried to do a plugin update via CLI and it returned <em>Failed to instantiate component or class &quot;modules\exifreturn\ExifReturn&quot;</em>, even though the update did actually complete. But after that, the front and backend of the site were displaying the same error.</p>
<p>I've seen a <a href="https://craftcms.stackexchange.com/questions/30529/failed-to-instantiate-component-or-class-when-calling-craft-module">similar question</a> already about this but the suggested fix in that question isn't working for me. I've also seen some discussion in Discord and have been looking at how NY Studio set up their <a href="https://github.com/nystudio107/devmode/tree/master/cms" rel="nofollow noreferrer">Devmode repo</a> and as far as I can tell, I've got things set up the same, so not sure why it's not working.</p>
<p>In <code>config/app.php</code> I have:</p>
<pre><code>return [
    'modules' =&gt; [
        'exifreturn' =&gt; [
          'class' =&gt; \modules\exifreturn\ExifReturn::class
        ]
    ],
    'bootstrap' =&gt; ['exifreturn'],
];
</code></pre>
<p>In <code>composer.json</code> I have:</p>
<pre><code>&quot;autoload&quot;: {
  &quot;psr-4&quot;: {
    &quot;modules\\exifreturn\\&quot;: &quot;modules/exifreturn/src/&quot;
  }
},
</code></pre>
<p>and on the server I have this in the modules folder:</p>
<p><a href="https://i.sstatic.net/LUD54.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/LUD54.png" alt="Screenshot" /></a></p>
<p>Can anyone see what I might be missing?</p>

<modules>
Failed to instantiate component or class error
# Failed to instantiate component or class error

(Asked by: username_0 on 2021-01-19)

I have a site with a custom module that was working fine until just recently but I tried to do a plugin update via CLI and it returned Failed to instantiate component or class "modules\exifreturn\ExifReturn", even though the update did actually complete. But after that, the front and backend of the site were displaying the same error.
I've seen a similar question already about this but the suggested fix in that question isn't working for me. I've also seen some discussion in Discord and have been looking at how NY Studio set up their Devmode repo and as far as I can tell, I've got things set up the same, so not sure why it's not working.
In config/app.php I have:
return [
    'modules' => [
        'exifreturn' => [
          'class' => \modules\exifreturn\ExifReturn::class
        ]
    ],
    'bootstrap' => ['exifreturn'],
];

In composer.json I have:
"autoload": {
  "psr-4": {
    "modules\\exifreturn\\": "modules/exifreturn/src/"
  }
},

and on the server I have this in the modules folder:

Can anyone see what I might be missing?

**Tags:** modules


---

## 1 answers

### Answer by username_1 on 2021-01-19. Score: 2 | Accepted answer

Make sure you have the correct namespace in your modules/exifreturn/src/ExifReturn.php class. From what you show, you should have:
namespace modules\exifreturn;

Right at the top, after . With that in place, run composer dumpautoload.

> **Comments:**
> **username_0**: Thanks username_1, `composer dumpautoload` did it! :)  

---

