# Debugging In Zend framework 3

**URL:** <https://discourse.laminas.dev/t/debugging-in-zend-framework-3/993>\
**Category:** Components & MVC\
**Tags:** zend-mvc\
**Created:** [March 18, 2019, 9:45am UTC](https://discourse.laminas.dev/t/debugging-in-zend-framework-3/993 "2019-03-18T09:45:10Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![swordfish](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@swordfish](https://discourse.laminas.dev/u/swordfish)\
**Post date:** [March 18, 2019, 9:45am UTC](https://discourse.laminas.dev/t/debugging-in-zend-framework-3/993/1 "2019-03-18T09:45:10Z")

</div>

I’ve just worked through the ZF3 tutorial and it isn’t working.

The error I get is:  
[Mon Mar 18 09:27:18 2019] PHP Fatal error: Uncaught Zend\ModuleManager\Exception\RuntimeException: Module (Album) could not be initialized. in /home/neily/test/zend/zf3-tutorial/vendor/zendframework/zend-modulemanager/src/ModuleManager.php:203

This is not very informative.I’ve spent some time going back through the tutorial looking for anything I’ve got wrong and also Googling this error, but I have had no luck identifying the problem.

Does anyone have any pointers?

It would be great if there was a list of common errors or a debugging guide to work through.

---

<div class="post-metadata">

**Author:** ![ocramius](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/ocramius/32/23_2.png) [@ocramius](https://discourse.laminas.dev/u/ocramius)\
**Post date:** [March 18, 2019, 10:01am UTC](https://discourse.laminas.dev/t/debugging-in-zend-framework-3/993/2 "2019-03-18T10:01:36Z")

</div>

This means that the class `Album\Module` couldn’t be autoloaded: this can be because the class is misplaced, because you have a typo in the file or class name, or because it is not in the Album namespace.

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [March 18, 2019, 10:36am UTC](https://discourse.laminas.dev/t/debugging-in-zend-framework-3/993/3 "2019-03-18T10:36:33Z")

</div>

Please check also your `composer.json` file:

[https://docs.zendframework.com/tutorials/getting-started/modules/#autoloading](https://docs.zendframework.com/tutorials/getting-started/modules/#autoloading)

This is often overlooked or forgotten.

---

<div class="post-metadata">

**Author:** ![swordfish](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@swordfish](https://discourse.laminas.dev/u/swordfish)\
**Post date:** [March 18, 2019, 10:37am UTC](https://discourse.laminas.dev/t/debugging-in-zend-framework-3/993/4 "2019-03-18T10:37:32Z")

</div>

The location is _…/zf3-tutorial/module/Album/src/Module.php_ and the file starts with  
_namespace Album;_

Both the namespace and the location appear correct to me?

---

<div class="post-metadata">

**Author:** ![swordfish](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@swordfish](https://discourse.laminas.dev/u/swordfish)\
**Post date:** [March 19, 2019, 10:40am UTC](https://discourse.laminas.dev/t/debugging-in-zend-framework-3/993/5 "2019-03-19T10:40:45Z")

</div>

My composer.json looks fine as well.

```
"autoload": {
    "psr-4": {
        "Application\\": "module/Application/src/",
    "Album\\": "module/Album/src/"
    }

```

I still have no clue why this isn’t working.

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [March 19, 2019, 10:49am UTC](https://discourse.laminas.dev/t/debugging-in-zend-framework-3/993/6 "2019-03-19T10:49:35Z")

</div>

Is your module registered?

[https://docs.zendframework.com/tutorials/getting-started/modules/#informing-the-application-about-our-new-module](https://docs.zendframework.com/tutorials/getting-started/modules/#informing-the-application-about-our-new-module)

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [March 19, 2019, 10:53am UTC](https://discourse.laminas.dev/t/debugging-in-zend-framework-3/993/7 "2019-03-19T10:53:30Z")

</div>

It would be helpful if you could deploy your project to GitHub and provide the link here.

---

<div class="post-metadata">

**Author:** ![ocramius](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/ocramius/32/23_2.png) [@ocramius](https://discourse.laminas.dev/u/ocramius)\
**Post date:** [March 19, 2019, 10:54am UTC](https://discourse.laminas.dev/t/debugging-in-zend-framework-3/993/8 "2019-03-19T10:54:48Z")

</div>

Few things to try out:

- try `composer dump-autoload` (it might be that the autoloader is still the one of when you first created the project)

- try `composer dump-autoload --optimize` (usually finds also classes that are in wrong locations, but in the correct path - if this works, then your path and class name mismatch)

- is your class in `namespace Album;`?

---

<div class="post-metadata">

**Author:** ![swordfish](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@swordfish](https://discourse.laminas.dev/u/swordfish)\
**Post date:** [March 19, 2019, 11:13am UTC](https://discourse.laminas.dev/t/debugging-in-zend-framework-3/993/9 "2019-03-19T11:13:38Z")

</div>

It is registered correctly, as far as I can see

```
return [
    'Zend\Form',
    'Zend\Db',
    'Zend\Router',
    'Zend\Validator',
    'Application',
    'Album',
];

```

composer dump-autoload doesn’t seem to help and adding --optimize doesn’t help either.  
The Module class is in namespace Album.

---

<div class="post-metadata">

**Author:** ![ocramius](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/ocramius/32/23_2.png) [@ocramius](https://discourse.laminas.dev/u/ocramius)\
**Post date:** [March 19, 2019, 11:24am UTC](https://discourse.laminas.dev/t/debugging-in-zend-framework-3/993/10 "2019-03-19T11:24:36Z")

</div>

Can you please show the file contents of your Module class?

---

<div class="post-metadata">

**Author:** ![swordfish](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@swordfish](https://discourse.laminas.dev/u/swordfish)\
**Post date:** [March 19, 2019, 11:44am UTC](https://discourse.laminas.dev/t/debugging-in-zend-framework-3/993/11 "2019-03-19T11:44:31Z")

</div>

Everything should be at [https://github.com/SaaSNSY/Zend3](https://github.com/SaaSNSY/Zend3)

---

<div class="post-metadata">

**Author:** ![ocramius](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/ocramius/32/23_2.png) [@ocramius](https://discourse.laminas.dev/u/ocramius)\
**Post date:** [March 19, 2019, 11:56am UTC](https://discourse.laminas.dev/t/debugging-in-zend-framework-3/993/12 "2019-03-19T11:56:58Z")

</div>

Your `Module.php` does not start with `<?php`

---

<div class="post-metadata">

**Author:** ![swordfish](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@swordfish](https://discourse.laminas.dev/u/swordfish)\
**Post date:** [March 19, 2019, 12:22pm UTC](https://discourse.laminas.dev/t/debugging-in-zend-framework-3/993/13 "2019-03-19T12:22:54Z")

</div>

OK. That makes a difference.  
Unless I’m misreading something that’s an error in the tutorial. The contents given at [https://docs.zendframework.com/tutorials/getting-started/modules/#setting-up-the-album-module](https://docs.zendframework.com/tutorials/getting-started/modules/#setting-up-the-album-module) do not start with \<?php.  
I possibly should have spotted that, but I have zero PHP experience, so it wasn’t immediately obvious to me.

---

<div class="post-metadata">

**Author:** ![swordfish](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@swordfish](https://discourse.laminas.dev/u/swordfish)\
**Post date:** [March 19, 2019, 1:15pm UTC](https://discourse.laminas.dev/t/debugging-in-zend-framework-3/993/14 "2019-03-19T13:15:00Z")

</div>

I think there are a lot of places in the tutorial where the \<?php at the start is just assumed. It is there in the .phtml code fragments, but not usually in the .php code fragments. Ideally, where it says to create a file with certain contents, it shouldn’t be omitting anything.

---

<div class="post-metadata">

**Author:** ![Luis\_Carlos\_Santos](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/luis_carlos_santos/32/1325_2.png) [@Luis\_Carlos\_Santos](https://discourse.laminas.dev/u/Luis_Carlos_Santos)\
**Post date:** [July 4, 2022, 8:47pm UTC](https://discourse.laminas.dev/t/debugging-in-zend-framework-3/993/15 "2022-07-04T20:47:29Z")

</div>

Friend, did you find the reason for the error? I really need to know…

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [July 4, 2022, 8:49pm UTC](https://discourse.laminas.dev/t/debugging-in-zend-framework-3/993/16 "2022-07-04T20:49:37Z")

</div>

Hello and welcome to our forums! 😃

Please create a new thread and describe your problem / error.  
Thanks in advance! 👍🏼
