New in Symfony 4.3: Deprecated the Templating component integration

The Symfony Templating component provides the tools needed to build any kind of template system, including the loading of template files from multiple sources, monitoring them for changes and using multiple engines to render them.

In Symfony applications this component allowed using both PHP and Twig to create the templates. However, nearly all developers use Twig to create traditional templates or use the serializer to output data. That's why in Symfony 4.3 we've decided to deprecate the integration of the Templating component in Symfony applications.

This means that, starting from Symfony 5.0, we will remove support for using PHP templates and PHP form themes. You'll need to use Twig for those templates. In addition to deprecating several classes, services and service tags, the hinclude_default_template configuration option has been moved to the fragments section:

1
2
3
4
5
6
# config/packages/framework.yaml
framework:
    # ...
-    templating:
+    fragments:
        hinclude_default_template: hinclude.html.twig

Although the number of people using PHP templates in Symfony applications is minimal compared to Twig, if enough people would volunteer to work on an alternative solution, we'd consider the creation of a new PHPTemplateBundle that provides all the deprecated classes and support files. If you are willing to help, create an issue in the main Symfony GitHub repository to kick off the discussion around this.

New in Symfony 4.3: Deprecated the Templating component integration symfony.com/blog/new-in-symfony-4-3-deprecated-the-templating-component-integration

Tweet this

Comments

Great news! 👍
Awesome...
That is unfortunate... we have long term migration plans for zend 1 projects to symfony and were planning to write a php template adapter for zend 1's phtml templates, this would be doomed now I suppose.
@Martin, we tried the same thing as you mention and eventually we got to the conclusion that it's better to just migrate to twig entirely (while migrating legacy app from ZF1 to S3).

For example, in order to support view helpers, you would have to recreate the magic from Zend or just drop their usage. We also had bootstrap 3 forms (with decorators, etc), so we had to load that "magic" of Zend forms into Symfony.
👍👍👍👍
I signed up for connect just so I could comment on this.

Why in the world would you remove PHP templating from a PHP framework? That is just the dumbest thing I have heard of.

Not everyone uses Twig. Why would you hitch your wagon to something that could go away or be replaced by the next new thing? Something that is so clearly a debatable choice for a development team. Use Twig if you like it, but if not PHP is always there - always has been.

Help write a package to support PHP in a PHP framework? For my team, it would probably be easier to just use a different framework. One that is not so opinionated.

I think this is a really stupid idea and I am disappointed that such a clearly one-sided decision was made.
@Justin if you used PHP templates in Symfony apps, we understand that you are upset about this proposed change. However, we made this decision consciously after asking lots of times to the community about their preferred language to create templates. What we've found is that the immense majority (in practice, almost all of them) use Twig.

Apart from that, what you said about Symfony being an opinionated framework is simply not true. In fact, Symfony is by far the less opinionated PHP framework. You don't have to take my word for it. Just look around the other frameworks and you'll quickly come to the same conclusion.

For example, you can configure Symfony using PHP, YAML or XML (YAML is only used by default for convenience; but everything is configurable with PHP and XML too). Meanwhile, other frameworks dictate the format you have to use to configure them. That's what being opinionated is all about.
Login with SymfonyConnect to post a comment