We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Blank page on for some actions

Hi,

I'm trying to configure my application on production server. On my local server everything works good. On production server (Ubuntu server 14.04, phpinfo here: https://pastebin.com/1dd8mTm8) on some actions I get a blank page.

For example: When I visit /controller/action1 I get blank page.

When I add to action1 this code: $this->view->pick('controller/action1') action1 works good.

Next I remove $this->view->pick('controller/action1') action1 works good. Edit: When I remove pick method action1 doesn't work

The question is why some actions produce a blank page without pick method?

edited May '14

I read source code of pick method. I see that it return $this, so i compare $this->view and $this->view->pick('settings/company'). Diff:

279 -   '_pickView' => null
279 +   protected '_pickView' => 
280 +     array (size=2)
281 +       0 => string 'settings/company' (length=16)
282 +       1 => string 'settings' (length=8)
edited May '14

Ok, probably I know what break views but I have no idea why it works on my dev machine and why doesn't work on production server. In my Routes i have code similar to this: https://github.com/phalcon/cphalcon/issues/284#issuecomment-11723075 which rewrites /controller/some-method to Controller::someMethodAction

// Route for controller action (support dashes in actions)
$router->add("/:controller/:action[/]?", array(
    'namespace' => 'App\Controllers\\',
    'controller' => 1,
    'action' => 2,
))->convert('action', function($action) {
    return Phalcon\Text::camelize($action);
});

// Route for controller action params (support dashes in actions)
$router->add("/:controller/:action/:params[/]?", array(
    'namespace' => 'App\Controllers\\',
    'controller' => 1,
    'action' => 2,
    'params' => 3
))->convert('action', function($action) {
    return Phalcon\Text::camelize($action);
});

This code change $this->view->action to uppercase. For example this url works:

/controller (executes controller/index) 

but this doesn't work:

/controller/index

When I rename /views/controller/index.volt to /views/controller/Index.volt everything is ok. Is possible to use URLs with dashes without renaming views?