View Naming Convension

Just a simple question:

My Controller have the name controllers/SunSystemController.php

I dont know whats the right way to spell the view name with multi word controller names








view/sun_system I think.


this is strongly something that is according to your preferences.

However the models/controllers do have a naming convention of capitalizing every first word.

eg. discussion_topic table > DiscussionTopicModel

edited Jan '15

This is a problem I'm trying to avoid, in tests i can only reach multi word actions like this "controller/fooBarBaz" or 'controller/foobarbaz'

If its a multi word controller, I can reach TermsAndConditionsController with localhost/terms-and-conditions/index, but actions doesn't behave that way, it has to be some-controller/termsandconditions.

I tried to do an event listener that is attached to the dispatcher to try and preprocess action names, but even in the listener call, i get pointed to my error 404 route if I access action with this name: multiWordAction with this url localhost/someController/multi-word

// My dispatch listener method
public function beforeDispatchLoop($event, $component)
    echo $component->getControllerName() ,' / '; // already list error controller
    echo $component->getActionName();

I'd like to find out how to solve this as well.


if you want the url to be exactly /terms-and-conditions or actions to be so.

You can alter your route, or dispatcher.

for route its the usual /controller/your-desired-url, array("controller" => "controller", "action" => "actual")

or dispatcher would be

Camelize action names something similar to that.


As 7thcubic says, you can alter your router ( ). And about the actions is as you say, doesn't behave that way. My links are like /my_controller/myAction.

Just to finish my thread hijack, the reason i got error controller and route404 in beforeDispatchLoop() is that i did not define any routing except the notFound():

// beforeDispatchLoop() gets error/route404 when the action does not exist
$di->set('router', function(){
    $router =  new \Phalcon\Mvc\Router();
    $router->notFound(array("controller" => "error", "action" => "route404"));
    return $router;

Need to be this:

// now, beforeDispatchLoop() gets the actual action from URL, so you can do something to it
$di->set('router', function(){
    $router =  new \Phalcon\Mvc\Router();

    $router->add('/:controller/:action/:params', array(
        'controller' => 1,
        'action' => 2,
        'params' => 3

    $router->notFound(array("controller" => "error", "action" => "route404"));
    return $router;