简体   繁体   中英

How to interpret Zend Framework 2 errors?

I just got this error:

Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with  message 'Module (ZfcUserOverride) could not be initialized.' in F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php:189 Stack trace: 
#0 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php(163): Zend\ModuleManager\ModuleManager->loadModuleByName(Object(Zend\ModuleManager\ModuleEvent)) 
#1 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php(90): Zend\ModuleManager\ModuleManager->loadModule('ZfcUserOverride') 
#2 [internal function]: Zend\ModuleManager\ModuleManager->onLoadModules(Object(Zend\ModuleManager\ModuleEvent)) 
#3 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(468): call_user_func(Array, Object(Zend\ModuleManager\ModuleEvent)) 
#4 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('loadModules', Object(Zend\ModuleManager\ModuleEvent), NULL) 
#5 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php(109): Zend\EventManager\EventManager->trigger('loadModules', Object(Zend\ModuleManager\ModuleManager), Object(Zend\ModuleManager\ModuleEvent)) 
#6 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php(252): Zend\ModuleManager\ModuleManager->loadModules() 
#7 F:\Server\domains\zf2-skeleton\public\index.php(17): Zend\Mvc\Application::init(Array) 
#8 {main} thrown in F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php on line 189

All, what I get from this error is understanding that problem is in ZfcUserOverride module. But is there any other usefull information "encryped" here :) ?

I'm answering your question, “How to interpret Zend Framework 2 errors.” I'm not addressing the error you encountered.

Identifying problem areas from ZF2 error reports can be a challenge. Yes, the stack trace provides useful information – it points out exactly where things went wrong. Unfortunately, what it says is where in the framework your code created a problem and not what part of your code created that problem. So, if you want to spend hours digging into the framework, everything is neatly listed for you. However, most of us use a framework to get away from the details, not to wrestle with them.

Here's what I do: The error message has three parts: File, Message and Stack Trace; and clues can be found in each:

File : Except in rare circumstances, I find the File part of the message to be useless. It might as well say, “you have a 'needle-in-a-haystack-error': happy hunting.”

Stack Trace : The Stack Trace part of the message is where I look first. While it simply lists locations in ZF2 framework that have ultimately led to the error, it will often identify some of your files, classes or variables that could have had some culpability. I don't see an example of any of your files in the stack trace above, but I often find traces of my own work listed here. In those instances, I scrutinize the suspect code for typos, bad syntax and other issues.

Message : If I don't find anything in the stack trace, I look into the message. I'm no ZF2 pioneer, so there's almost always someone who has encountered the same error before me. I copy the entire error message and paste it into my favorite search engine (deleting my unique paths, of course). The SO hits tend to be the most helpful so I go there first. To save time, I skip over the question and go right to the answer because the questioner is often as lost as I am and has presented a whole lot of haystack info in search of his needle. The answer(s) might say something like “it appears that you didn't tie your shoes this morning,” which often causes me to say, “Hey, wait a second! I forgot to tie my shoes this morning, too,” and off I go to review the code for my shoe-tying method.

For example, searching Module (ZfcUserOverride) could not be initialized.' in Zend\\ModuleManager\\ModuleManager.php:189 Module (ZfcUserOverride) could not be initialized.' in Zend\\ModuleManager\\ModuleManager.php:189 leads to the SO question Zend Framework 2 tutorial: Module (Application) could not be initialized , which may have an answer that is pertinent to your problem.

If existing SO answers don't point me in the right direction, I ask one of my own.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM