A Latte template view for Bitty.

v1.0.1 2019-01-19 21:41 UTC

This package is auto-updated.

Last update: 2023-05-16 12:58:48 UTC


Build Status Codacy Badge PHPStan Enabled Mutation Score Total Downloads License

A Latte template view for Bitty.


It's best to install using Composer.

$ composer require bittyphp/view-latte


Basic Usage



use Bitty\Application;
use Bitty\View\Latte;

$app = new Application();

$app->getContainer()->set('view', function () {
    return new Latte(dirname(__DIR__).'/templates/', $options);

$app->get('/', function () {
    return $this->get('view')->renderResponse('index.latte', ['name' => 'Joe Schmoe']);




use Bitty\View\Latte;

$latte = new Latte(
        // Sets the path to the cache directory.
        // Defaults to system tmp folder.
        'cacheDir' => '/path/to/cache',

        // Whether to auto-refresh templates when the file changes.
        'refresh' => true,

        // Template content type.
        // @see Latte\Engine::CONTENT_* constants.
        'contentType' => 'html',

Adding Filters

One of the great things about Latte is that you can easily extend it to add you own custom functionality. This view would not be complete without allowing access to that ability.

See Latte's filter docs for more info.


use Bitty\View\Latte;

$latte = new Latte(...);

$latte->addFilter('someFilterName', function ($value) {
    return strtolower($value);


If you need to do any advanced customization, you can access the Latte engine and loader directly at any time.


use Bitty\View\Latte;
use Latte\Engine;
use Latte\ILoader;

$latte = new Latte(...);

/** @var Engine */
$engine = $latte->getEngine();

/** @var ILoader */
$loader = $latte->getLoader();