symfony/templating
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
symfony/deprecation-contracts | v3.5.0 | - | MIT | prod | |
symfony/polyfill-ctype | v1.29.0 | - | MIT | prod |
The Symfony Templating component, symfony/templating
, provides a robust suite of tools necesary to create any kind of template system. This package provides the infrastructure needed to load and optionally monitor template files for changes. It offers a concrete PHP template engine implementation, with additional tools aimed at escaping and segmenting templates into blocks and layouts.
Installation and usage of the symfony/templating
package is simple. Begin by integrating it into your project using Composer:
$ composer require symfony/templating
After installation, you can utilize it within your project as follows:
use Symfony\Component\Templating\Loader\FilesystemLoader;
use Symfony\Component\Templating\PhpEngine;
use Symfony\Component\Templating\Helper\SlotsHelper;
use Symfony\Component\Templating\TemplateNameParser;
$filesystemLoader = new FilesystemLoader(__DIR__.'/views/%name%');
$templating = new PhpEngine(new TemplateNameParser(), $filesystemLoader);
$templating->set(new SlotsHelper());
echo $templating->render('hello.php', ['firstname' => 'Fabien']);
// hello.php
Hello, <?= $view->escape($firstname) ?>!
In this example, FilesystemLoader
, PhpEngine
, SlotsHelper
, and TemplateNameParser
are used from Symfony's Templating package. The template file hello.php
renders a simple greeting, with a firstname variable that is escaped for safe output.
Detailed documentation and resources for symfony/templating
can be found within the main Symfony repository. Additional resources for contributing to the project, reporting issues, and submitting pull requests are also available. For particular concerns or specific use cases, the Symfony community can be a valuable resource.