Search code examples
zend-frameworkzend-framework-mvc

Correct way of MVC folder structure in Zend Framework


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


Solution

  • 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