Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.3.2] Volt Compiler addFunction as closure #2574

Closed
meetmatt opened this issue Jun 28, 2014 · 5 comments
Closed

[1.3.2] Volt Compiler addFunction as closure #2574

meetmatt opened this issue Jun 28, 2014 · 5 comments

Comments

@meetmatt
Copy link

Adding and later using a Volt function using closure results in script termination during compilation.

Example:

<?php
// www/index.php
$di = new Phalcon\DI\FactoryDefault();

$di->set('view', function () {
        $view = new Phalcon\Mvc\View();
        $view->setViewsDir('../app/views/');
        $view->registerEngines([
                '.volt' => function($view, $di) {
                        $volt = new Phalcon\Mvc\View\Engine\Volt($view, $di);
                        $volt->getCompiler()->addFunction('foo', function($args) {
                            return "'bar'";
                        });
                        return $volt;
                }
        ]);

        return $view;
});

$app = new Phalcon\Mvc\Application($di);
$response = $app->handle(); // terminates here
echo $response->getContent(); // unreachable

Volt template:

{# app/views/index.volt #}
{{ foo() }}

It seems that execution is terminated while trying to compile Volt template to PHP file.

Ubuntu 12.04 x64
PHP 5.5.13-2
Phalcon 1.3.2

@meetmatt meetmatt changed the title 1.3.2 Volt Compiler addFunction as closure causes fatal errors [1.3.2] Volt Compiler addFunction as closure causes fatal errors Jun 28, 2014
@meetmatt meetmatt changed the title [1.3.2] Volt Compiler addFunction as closure causes fatal errors [1.3.2] Volt Compiler addFunction as closure Jun 28, 2014
@oh-ren
Copy link

oh-ren commented Jun 28, 2014

Do you have Xdebug running?

@meetmatt
Copy link
Author

Yes, i tried setting a breakpoint inside closure at return "'bar'" and it doesn't break there obviously terminating before. I wish I could debug the php process, just don't know how and what to look for.

@meetmatt
Copy link
Author

Disabling xdebug extension solved the issue, thank you!
Didn't know that xdebug and phalcon have compatibility problems, I think it's quite a critical issue.
At least this info should be added somewhere in the documentation.

@oh-ren
Copy link

oh-ren commented Jun 29, 2014

Yes, it's not very pretty I guess.. Regarding the docs; the core team is small, and the project for a large part depends on contributions from others. Perhaps I could add something to the docs and create a PR for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants