cphalcon: Class not found error when Controller has uppercase letters in class & its file name
I have setup Php 5.5, Phalcon 1.3.1 on 64bit Linux on a shared hosting server. I was able to run my application on Wamp on Windows 7 with Phalcon 1.3.1 & Php 5.5 but when I moved the application to production on a Linux 64 bit (most probably CentOS) I got the below error:
Fatal error: Uncaught exception 'Phalcon\Mvc\Dispatcher\Exception' with message 'CIAB\Controllers\ChooseprojectController handler class cannot be loaded' in /home/myproj/public_html/ciab/public/index.php:35
Stack trace: #0 [internal function]: Phalcon\Mvc\Dispatcher->_throwDispatchException('CIAB\\Controller...', 2)
#1 [internal function]: Phalcon\Dispatcher->dispatch()
#2 /home/myproj/public_html/ciab/public/index.php(35): Phalcon\Mvc\Application->handle()
#3 {main} thrown in /home/myproj/public_html/ciab/public/index.php on line 35
It looks like Phalcon doesn’t allow uppercases in Controller class and file names except as the first letter. To get rid of this error I had to change the controller class name and the name of the file containing the class, i.e. ChooseProjectController.php, with a lower case ‘P’. As mentioned earlier, it worked fine on Windows but on linux it didn’t till I changed as above. You should easily be able to recreate this bug and it seems to be related to an older bug Error parsing annotations router #1040 bug. I am new to Github so I hope this is the correct way to inform you of a potential bug.
Regards
<bountysource-plugin>
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 43 (6 by maintainers)
Guys, how is this not a bug? If the first character is uppercase, the rest can’t just be bulldozed into lower case. Either you use camel case or you use some other standard. Forcing single-word controller names is just weird and counter intuitive. Naming convention is a big deal. Also, adding routes manually sounds very much like a workaround to me, rather than a proper solution. If there’s implicit routing, it should use the same naming conventions as the rest of the framework.
Personally, I have a UrlCamelizer plugin that takes hyphened URLs (/choose-project) in accordance with Google’s recommendations and converts to camel case for matching with the Controller / Action names. When the Controller name has been set, Phalcon rewrites my rewrites, breaking the URLs. This must be fixed, in my opinion.
Lastly, not to sound negative, I want to say that Phalcon is an AWESOME framework and I love it! Thanks for your hard work, Phalcon Team!
I use temporary solve someControllerName -> some-controller-name SomeControllerName -> some-controller-name
@UndergroundLabs it shouldn’t be camel-cased
You can do it. Your URL must look like choose_project/yourAction
@phalcon We just need to add 2 cases in your example:
Maybe I am wrong since I did not check the source code yet, but I see no reason the last 2 cases will break the code for the first 3 cases.
@olivezuo The reason why it doesn’t occur on MacOS is because it’s case insensitive by default, which CentOS is not. I’d like to see this issue reopened from Phalcon, it is definitely a bug.