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

Action views not rendered in production.

I am encountering a strange issue in my production environment whereby action views are not displayed.

Both my development and production environment run on nginx. In development i have no issues - everything works perfectly.

On production however, although my main layout loads, my action views do not - the area where they should be is simply blank.

My access logs and error logs show no red flags.

The only differences in my environments are that I am developing on Mac OS (although I dont believe it to be a file path name issue) whereas my production server runs on Ubuntu. My virtual host setup is also different. I however find it strange that all my files load correctly - my controllers are loading fine, the main layout is, and static content files load fine.

The only situation in which action views do render is when the dispatcher is forwarding a request.

Could anyone advise on what could be causing this strange issue?

Many Thanks T



98.9k

Mac OS X has case insensitive filesystems and Linux case sensitive filesystems, this maybe the reason why Linux can't find your views.

Thanks for the response. I was aware of Mac OS and filesystem quirks but did not investigate fully enough - this was the problem.

It would seem that Phalcon expects capitalized view names. View names also seem to need an underscore as a separator if your action method is multiple words. I naively assumed it would be the other way around and thus discounted this as being the issue.

doStuffAction expects a view called Do_stuff for example.



6.4k

Hi,

I had many issues with that, too. Especially when using the annotations router. The behaviour changed through the different phalcon version, but still isn't consistent.

You can take a look at my demo, here: https://github.com/Plaputta/Phalcon-CamelCase-Demo

To solve that issue, I've created a new annotations router that (imo) doesn't mess with the controller/action names. So if you want to use annotations, take a look at: https://github.com/Plaputta/Phalcon-camelCase-Annotations-Router

Now with Phalcon 1.2.6 and the abovementioned annotations router, I can finally do:

$this->dispatcher->forward(array('controller'=>'myTest', 'action'=>'awesomeTest'));```

and add routes like this:

```php
class MyTestController extends Controller
{
    /**
     * @Get("/test-action", name="test")
     *
     */
    public function awesomeTestAction()
    {
       $this->view->setVar('date', date('Y-m-d'));
    }

and it all will look for the view /views/myTest/awesomeTest.phtml

Hope that helps a bit..

Toby