user775171
user775171

Reputation:

Include a PHP file in a Twig template

I need to include a PHP script in my twig template. Is this possible?

Upvotes: 1

Views: 3950

Answers (1)

apfelbox
apfelbox

Reputation: 2634

You would not want to do that. What you can do is to create a twig extension and run your PHP code there. In your template you would just call your extension:

{{ myExtension() }}

Upvotes: 3

Related Questions