Case insensitive path for views & layouts files


First, I want to thank you for the outstanding work you have done with the Phalcon project.

I'm trying to switch from a custom Zend Framework webapp working only by namespaced conventions to your framework and I have the following problem:

All my files views are namespaced classes (as all my php files), for example the view file for the controller Index and the action Foo is in the directory MY_APP_PATH/View/Index/Foo.php.

I wrote a Phalcon view engine to handle my view file as classes but the Phalcon/Mvc/View does not found the file MY_APP_PATH/View/Index/Foo.php, it only finds MY_APP_PATH/View/index/foo.php

I don't understand why you force the code $view->render('A', 'b') to render the file a/b.ext instead of A/B.ext…

How can I hack this feature, it seems to be the only problem switching my webapp to Phalcon.



Try modifying the way Phalcon pass parameters to the view component:


class CustomRenderer extends Phalcon\Mvc\User\Plugin
    public function viewRender($event, $application, $view)
      $dispatcher = $this->dispatcher;

      $controllerName = str_replace('\\', DIRECTORY_SEPARATOR, $dispatcher->getNamespaceName()) . 
              DIRECTORY_SEPARATOR . 

      $view->render($controllerName, $dispatcher->getActionName(), $dispatcher->getParams());

The plugin must be attached to the application:

$evManager->attach('application:viewRender', new CustomRenderer());
$app = new Phalcon\Mvc\Application($di);

Thank for your quick answer ; I now understand how I can bypass the default parameters to the view component.

However, I think it's a bad design to force the lower case of controller name and action name. Puting this code in my startup file app

$di = new \Phalcon\DI\FactoryDefault();
    function() use ($controllerNamespace, $controllerName, $action) {
        $dispatcher = new \Phalcon\Mvc\Dispatcher();

        return $dispatcher;

and this code

die("<pre>\n" . $dispatcher->getControllerName() . '::' . $dispatcher->getActionName() . "</pre>\n");

in the method viewRender of my custom mvc user plugin, I obtain index::index. I cant figure why the setter modify the value that I want to set. It's a bad design to call a controller class named Index when the controllerName of the dispacher is index. "Zend Framework", "Symfony Framework", the PHP "Framework Interop Group" tend to standardes naming convention that help developper to have a reliable architecture as Java has. I suggest you to read this repository