Integrations

Learn how to integrate the Tplix PHP template engine with popular frameworks including Laravel, Symfony, CodeIgniter, Yii, Slim, Laminas, CakePHP, Phalcon, FuelPHP, and Hyperf. Step-by-step code examples for every framework.

Framework Integrations

Plug Tplix into Any PHP Framework

Tplix is framework-agnostic. One Composer install is all it takes — then follow the guide for your framework below.

Install composer require tplix/tplix

Choose your framework

Laravel

v9 · v10 · v11
L

Register as a singleton in a service provider and inject via Laravel's DI container.

$app->singleton(Tplix::class, fn() => ...);
View Integration Guide →

Symfony

v5 · v6 · v7
S

Wire Tplix into the Symfony service container via a YAML factory definition.

factory: ['Tplix\Tplix', 'getInstance']
View Integration Guide →

CodeIgniter

CI3 · CI4
C

Simple library wrapper for CI3 and a namespace-aware service class for CI4.

$this->tpl = Tplix::getInstance();
View Integration Guide →

Yii 2

v2.x
Y

Register a Tplix component in the application config and use it from any controller.

'class' => 'app\components\TplixComponent'
View Integration Guide →

Slim

v4
S

Register in the PHP-DI container and inject into route handlers or action classes.

$builder->addDefinitions([Tplix::class => ...]);
View Integration Guide →

Laminas

MVC · Mezzio
L

Wire Tplix through the Laminas service manager factory in module config.

Tplix::class => function() { return ...; }
View Integration Guide →

CakePHP

v4 · v5
C

Create a custom View class extending CakePHP's base View and set it per controller.

class TplixView extends View { ... }
View Integration Guide →

Phalcon

v5
P

Register as a shared service in Phalcon's FactoryDefault DI container.

$di->setShared('tplix', function() { ... });
View Integration Guide →

FuelPHP

v1.x
F

Wrap Tplix in a FuelPHP-style static class and load it as an application package.

Tplixer::forge()->render('home.tpl');
View Integration Guide →

Hyperf

v3 · Swoole
H

Register as a singleton in Hyperf's DI container with a Swoole-safe clear-assign pattern.

Tplix::class => function() { ... }
View Integration Guide →

Every Integration Follows the Same Pattern

Framework-specific wiring differs, but the Tplix API is always identical.

1

Get Instance

Tplix::getInstance()

Tplix is a singleton — call once, share everywhere.

2

Assign Variables

$tplix->assign('key', $val)

Pass any PHP value — arrays, objects, scalars.

3

Fetch Template

$tplix->fetch('view.tpl')

Returns rendered HTML. Return it as the response.

♥ Support Tplix