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

Volt engine always crash PHP, 502 Bad Gateway

Hi, I have been trying a whole day to fix a crashing problem; it narrows down to volt engine. The website renders fine on my virtual box, but on my VPS volt always crash whenever it renders a view.

Is there an easy way to debug volt crashes?

  • tried to upgrade & disable xdebug, not working
  • applied all updates for php5.5 and centos

Error message: 502 Bad Gateway

The most headache part is, it works okay on my virtual box with almost the same setup.

Here is the phpinfo() from the server crashes: https://dovps1.woapp.info/pi.php

It is very smimilar to my dev box. Same Kernel version, php, phalcon.

The Controller and Vews are really simple, just a 1 line test case:

class IndexController extends \Phalcon\Mvc\Controller
{
    public function indexAction()
    {
        echo __FUNCTION__." in ".__FILE__." at ".__LINE__."<br/>";
        $this->view->pick("test");
    }

test.volt

<html>
<body>
<h3>This is VOLT view!</h3>
</body>
</html>

Here is how I register volt:

$di->set('view', function() {

  $view = new \Phalcon\Mvc\View();
  $view->setViewsDir(__DIR__.'/views/');
  //$view->setTemplateBefore('main');

  $view->registerEngines(array(
    ".volt" => function($view, $di) {
      $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);
      $volt->setOptions(array(
        "compiledPath" => DIR_ROOT."/var/volt/",
        "compiledExtension" => ".php",
        'compiledSeparator' => '_',
        "compileAlways" => false
      ));
      return $volt;
    },
      '.phtml' => 'Phalcon\Mvc\View\Engine\Php' // Generate Template files uses PHP itself as the template engine
  ));
  return $view;
}, true);

Thanks!



51.1k

Check the permissions on DIR_ROOT."/var/volt/"

the problem is the "compiledPath" function can't write cache files into the DIR_ROOT."/var/volt/". If you delete it, your application will work but all of cached volt file will be written in the current folder by default(./). Maybe you can try to run sudo command to give the DIR_ROOT."/var/volt/" the write permission.



5.3k
Accepted
answer
edited Mar '15

checked the dir permission, they are set correctly. PHP-FPM & Nginx run as 'nginx' user.

drwsrwsr-x 2 nginx nginx 4096 Mar  2 17:40 volt

I suspect there is something installed on my VPS that conflicts with phalcon/volt. The VPS I am using has multiple sites and the PHP installation had a few changes in the past.

Just spun up a new(clean) VPS and things work good.

But if anyone can tell me how to debug volt crash, I'd be happy to provide some info. Maybe there is an undiscovered bug somewhere.