如何使用简单的格式化生成zf2输出错误?

时间:2014-04-30 00:43:01

标签: php error-handling zend-framework2 stack-trace

我是zf2框架的新手。例如,现在我收到此错误:

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

我手动格式化,因此您可以阅读正确的错误。

我遇到一些错误时很难做到这一点。如何让zf2正确输出这些错误?

我需要这样的东西:

enter image description here

1 个答案:

答案 0 :(得分:0)

ZendSkeletonApplication附带一个模板,以可读格式报告错误。如果您安装ZendSkeletonApplication并从中构建应用程序,您将受益于此模板和其他便利。或者,您可以只使用standard error template或创建自己的。