Debugging In Zend framework 3

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.

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.

Please check also your composer.json file:

This is often overlooked or forgotten.

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?

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.

Is your module registered?

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

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;?

It is registered correctly, as far as I can see

return [

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

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

Everything should be at

Your Module.php does not start with <?php

OK. That makes a difference.
Unless I’m misreading something that’s an error in the tutorial. The contents given at 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.

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.

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

Hello and welcome to our forums! :smiley:

Please create a new thread and describe your problem / error.
Thanks in advance! :+1:t3: