I am a beginner working with Zend Framework, and currently having a small problem:
I am creating a project based on modular architecture and requesting this URL:
http://localhost/MyApp/public/ –> which is where index.php resides. My core module is called “core” inside /application/modules directory as follows:
/Applications/modules/
-- Core
---- controllers
------ ErrorController.php
------ IndexController.php
---- views
------ scripts
-------- error/error.phtml
-------- index/index.phtml.
Everytime i refresh the page i get error.phtml displayed which is weird. Because my module does define it’s routes as follows:
[routes]
routes.core_index_index.type = "Zend_Controller_Router_Route_Static"
routes.core_index_index.route = "/"
routes.core_index_index.defaults.module = "core"
routes.core_index_index.defaults.controller = "index"
routes.core_index_index.defaults.action = "index"
routes.core_index_index.defaults.frontend = "true"
routes.core_index_index.defaults.langKey = "route_index_page_description"
routes.core_index_index.defaults.localization.enable = "true"
Plus the fact that i do have RewriteBase set to /var/www/html/MyApp/public. So why is my error.phtml being displayed while index.phtml should be the view script to be rendered?
Following is my setup for production config in application.ini
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.defaultModule = core
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.frontController.params.prefixDefaultModule = "1"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
Content of error page being displayed:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Zend Framework Default Application</title>
</head>
<body>
<h1>An error occurred</h1>
<h2>Page not found</h2>
</body>
</html>
Any help is truly appreciated.
Okay, i got this to work:
Since am requesting http://localhost/MyApp/public/, i had to modify the routing to:
Change was from:
To:
Which is not exactly what i was looking for. Is there a way to skip /MyApp/public part of the URI?