Download the PHP package cloudbase/latte-helper without Composer
On this page you can find all versions of the php package cloudbase/latte-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cloudbase/latte-helper
More information about cloudbase/latte-helper
Files in cloudbase/latte-helper
Package latte-helper
Short Description An unofficial helper package for rendering Latte templates in Symfony applications.
License GPL-3.0-or-later
Informations about the package latte-helper
Latte Helper
An unofficial helper package for rendering Latte templates in Symfony applications.
🚀 Installation
Then add the following to the imports section in your config/services.yaml:
You'll also need to add some configuration for your Latte controllers:
You don't need to add this for every single controller, this is just a reference to the directory where your controllers are stored. Add this definition for each directory containing Latte controllers. This does however mean that every controller inside that directory is expected to be an extension of
AbstractLatteControllercontroller.
🧩 Usage
This package provides an abstract controller to simplify rendering Latte templates in Symfony. To get started, extend
AbstractLatteController and use renderTemplate():
By default, templates are loaded from your project’s /views directory. You can change this by setting the $templateDir
property on your controller.
🏗️ Custom Template Directory
If you use a different directory, it’s recommended to create a base controller that others extend:
The example above renders /templates/frontend/index.latte.
$templateDir should always be relative to your project root.
💡 Template Variables
Every template automatically receives an $app variable - an instance of LatteAwareApplication.
This provides access to some common Symfony features (similar to the app variable in Twig):
⚙️ Using $app in Controllers
You can also access the same application instance within your controller:
🌐 Global Template Data
Need data available across multiple templates?
Override the globalData() method in your base controller:
All controllers inheriting from this class will have access to $myGlobal in addition to $app and local template
variables.
🧩 Custom Latte Extensions
To register your own Latte extensions, create a config/latte.php file in your Symfony project.
This file should return an array of class names and their constructor arguments:
This allows you to use custom Latte tags, filters, and functions throughout your templates.
All versions of latte-helper with dependencies
latte/latte Version ^3.0
symfony/http-foundation Version ^8.0
symfony/framework-bundle Version ^8.0
symfony/security-bundle Version ^8.0