Zend Framework 中 MVC 文件夹结构的正确方式

发布于 2025-01-07 10:48:03 字数 1567 浏览 1 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

冰魂雪魄 2025-01-14 10:48:04
  Controller Name = Directory Name
  Action     Name = file.phtml
  Controller Name = Directory Name
  Action     Name = file.phtml
芸娘子的小脾气 2025-01-14 10:48:04

尝试以下结构:

application/
    browsinghistory/
        controllers/
            BrowsinghistoryController.php
        models/
        views/
            scripts/
                browsinghistory/
                   browsinghistory.phtml

并将控制器的名称更改为 BrowsinghistoryController

class BrowsinghistoryController extends Zend_Controller_Action{//my actions }

Try the followig structure :

application/
    browsinghistory/
        controllers/
            BrowsinghistoryController.php
        models/
        views/
            scripts/
                browsinghistory/
                   browsinghistory.phtml

and change your controller's name to BrowsinghistoryController :

class BrowsinghistoryController extends Zend_Controller_Action{//my actions }
执手闯天涯 2025-01-14 10:48:03

您只需将 /scripts 下的 BrowsingHistory 文件夹重命名为 browsing-history 即可解决您的问题!

基本上,控制器和操作都是驼峰命名法,但脚本不是,您只需将每个大写字母转换为小写字母并添加破折号,如下所示:

  • camelCase 变为 camel -case
  • camelCaseTest 变为camel-case-test
  • BrowsingHistory 变为浏览历史记录

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:

  • camelCase becomes camel-case
  • camelCaseTest becomes camel-case-test
  • BrowsingHistory becomes browsing-history
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文