Zend Framework 中 MVC 文件夹结构的正确方式
我在 MVC 中的文件夹命名中遇到问题,这就是为什么出现以下错误。
Fatal error: Uncaught exception 'Zend_View_Exception' with message 'script'browsing-
history/browsinghistory.phtml' not found in path (C:/xampp/htdocs/test_app/application
/views\scripts/)' in C:\xampp\htdocs\test_app\library\Zend\View\Abstract.php:988 Stack
trace: #0 C:\xampp\htdocs\test_app\library\Zend\View\Abstract.php(884):
Zend_View_Abstract->_script('browsing-histor...') #1 C:\xampp\htdocs\test_app\library
\Zend\Controller\Action\Helper\ViewRenderer.php(900):
Zend_View_Abstract->render('browsing-histor...') #2 C:\xampp\htdocs\test_app\library
\Zend\Controller\Action\Helper\ViewRenderer.php(921):
Zend_Controller_Action_Helper_ViewRenderer->renderScript('browsing-histor...', NULL)
#3 C:\xampp\htdocs\test_app\library\Zend\Controller\Action\Helper
\ViewRenderer.php(960): Zend_Controller_Action_Helper_ViewRenderer->render() #4
C:\xampp\htdocs\test_app\library\Zend\Controller\Action\HelperBroker.php(277):
Zend_Controller_Action_Helper_ViewRenderer->postDispatch() #5 C:\xampp\htdocs\test_app
\library\Zend\Controller\Action.php in C:\xampp\htdocs\test_app\library\Zend\View
\Abstract.php on line 988
这是我的控制器,
class BrowsingHistoryController extends Zend_Controller_Action{//my actions }
这是我的操作
public function browsinghistoryAction(){}
,这是我在脚本中的文件夹结构,
scripts
->BrowsingHistory
->browsinghistory.phtml
我对我的控制器做了同样的事情,工作正常,不知道为什么这不起作用?任何想法
i have problem in folder Naming in MVC thats why getting the following errors.
Fatal error: Uncaught exception 'Zend_View_Exception' with message 'script'browsing-
history/browsinghistory.phtml' not found in path (C:/xampp/htdocs/test_app/application
/views\scripts/)' in C:\xampp\htdocs\test_app\library\Zend\View\Abstract.php:988 Stack
trace: #0 C:\xampp\htdocs\test_app\library\Zend\View\Abstract.php(884):
Zend_View_Abstract->_script('browsing-histor...') #1 C:\xampp\htdocs\test_app\library
\Zend\Controller\Action\Helper\ViewRenderer.php(900):
Zend_View_Abstract->render('browsing-histor...') #2 C:\xampp\htdocs\test_app\library
\Zend\Controller\Action\Helper\ViewRenderer.php(921):
Zend_Controller_Action_Helper_ViewRenderer->renderScript('browsing-histor...', NULL)
#3 C:\xampp\htdocs\test_app\library\Zend\Controller\Action\Helper
\ViewRenderer.php(960): Zend_Controller_Action_Helper_ViewRenderer->render() #4
C:\xampp\htdocs\test_app\library\Zend\Controller\Action\HelperBroker.php(277):
Zend_Controller_Action_Helper_ViewRenderer->postDispatch() #5 C:\xampp\htdocs\test_app
\library\Zend\Controller\Action.php in C:\xampp\htdocs\test_app\library\Zend\View
\Abstract.php on line 988
this is my Controller
class BrowsingHistoryController extends Zend_Controller_Action{//my actions }
this is my action
public function browsinghistoryAction(){}
and this is my folder structure in scripts
scripts
->BrowsingHistory
->browsinghistory.phtml
i did the same thing for my controllers thats working fine dont know why this is not working ?? Any idea
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试以下结构:
并将控制器的名称更改为
BrowsinghistoryController
:Try the followig structure :
and change your controller's name to
BrowsinghistoryController
:您只需将
/scripts
下的BrowsingHistory
文件夹重命名为 browsing-history 即可解决您的问题!基本上,控制器和操作都是驼峰命名法,但脚本不是,您只需将每个大写字母转换为小写字母并添加破折号,如下所示:
You just need to rename the
BrowsingHistory
folder under/scripts
into browsing-history and your problem will be gone!Basically, controllers and actions are in camelCase, but scripts aren't, you just need to transform and replace every capital letter in lower-case letter and add a dash as follow: