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:
https://docs.zendframework.com/tutorials/getting-started/modules/#autoloading
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.
It would be helpful if you could deploy your project to GitHub and provide the link here.
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.
Can you please show the file contents of your Module class?
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 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.
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…
1 Like
Hello and welcome to our forums!
Please create a new thread and describe your problem / error.
Thanks in advance!