Reputation: 7493
this is weird I've been hacking away for a while at this error. It seems to show up only on the deployment server. I have a perfectly working controller named holidays - here is the structure of the controller and the view:
controllers
-> HolidaysController.php
<?php
class HolidaysController extends App_Controller_Action {
public function indexAction() {
.....
}
}
?>
My views file is in
views/scripts/holidays/index.phtml
when I navigate to website.com/holidays
it give me this error:
An error occurred
Page not found
Exception information:
Message: Action "index" does not exist and was not trapped in __call()
Stack trace:
#0 /home/bookitfa/bookings/library/Zend/Controller/Action.php(515): Zend_Controller_Action->__call('indexAction', Array)
#1 /home/bookitfa/bookings/library/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('indexAction')
#2 /home/bookitfa/bookings/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#3 /home/bookitfa/bookings/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#4 /home/bookitfa/bookings/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#5 /home/bookitfa/bookings/public/index.php(29): Zend_Application->run()
#6 {main}
Request Parameters:
array (
'controller' => 'holidays',
'action' => 'index',
'module' => 'default',
)
But when I navigate to website.com/Holidays
it works for some odd reason. All other controllers work fine except this certain controller seems to only work if the controller name has the first letter uppercase. Why is that? This is a zend framework based application. All my urls would be out of place like this.
EDIT =======
The strange paart is that irrespective of what I keep the filename i.e HolidaysController.php or holidaysController.php - online I can only access it by /Holidays and not by /holidays, this is a very serious issue here and I've run out of ideas on how to resolve it :(
Upvotes: 0
Views: 1256
Reputation: 17710
Class names in Zend are case sensitive - on Linux.
Why? Because it only loads the class file it needs, and file names on Linux are case sensitive.
You're probably dev'ing on Windows, which is not case sensitive. When asking for file "holidaysController.php" windows will return HolidaysController.php, holidayscontroller.php or HoLiDaYsCoNtRoLlEr.php - you get the idea! It looks for the file, then loads only that file.
On Linux (and Mac) those 4 filenames are all different. Even though you've named the class according to the docs (upper case for classes, camel for actions) you need to also call the router with the same case - otherwise the file won't be found and loaded.
Why it gets confusing: Zend tries to normlise to lower case so it's looking for "holidayController.php" first (when you enter "Holiday"). It gets a bit complicated with mixed cases: see the yellow box on this page : so it failed to find the normlaised so is treating as mixed case, which then works. When you enter "holiday" it fails to find the file, but as it's not been normalised or camelcase, it doesn't need ot look for any other file. It just fails.
Your options: stay with "Holidays" as the route for that file, or rename the file as "holidayController.php" and you can run with Holiday or holiday. (Leave the class as HolidayController - that bit is not case sensitive).
Upvotes: 2