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

Rendering output to variable returns empty string in prod server

I have phalcon 3.4.4 installed on windows 01 with php 7.3.7 in my local machine.

i have following code

     <?php
        $view = $this->view;
        $view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_ACTION_VIEW);
        $view->render("", "testtest");
        $content = $view->getRender('', "testtest", array("name"=>"Mr. XYZ"), function($view)
        {
            $view->setRenderLevel(View::LEVEL_ACTION_VIEW);
        });
        echo $content;
        exit;

And Another way to get same output

    <?php
    $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);       
    $content = $this->view->getRender('', "testtest", array("name"=>"Mr. XYZ"), function($view)
    {
        $view->setRenderLevel(View::LEVEL_LAYOUT);
    });    

    echo $content;
    exit;

Both of the above code snippets works perfectly fine in my local machine.

But in production server $content returns empty string. No errors displayed and no errors in error logs. The production server is ubuntu with php 7.3.6 with phalcon 3.4.3

Can anybody help me on this what might be wrong, did I miss anything?

Thanks.

Check your server log. For instance if the view folder is not writeable that could cause this to happen.

Check your server log. For instance if the view folder is not writeable that could cause this to happen. No errors in server's log. But I used simple view instead and that worked