Luminova Framework

PHP Luminova: Default Template Engine and Rendering Mode Configuration

Last updated: 2025-12-03 19:49:36

Choose your template engine, adjust caching, and control how pages are rendered to fit your project’s needs.

The Template Configuration in Luminova allows you choose and customize your template rendering engine like PHP, Twig, or Smarty. You can set rendering modes, define cache paths, control template visibility, and enable extra extensions for Twig or Smarty as needed. For more information see View Rendering documentation.


Class Definition

  • Class namespace: \App\Config\Template
  • File path: /app/Config/Template.php
  • This class is marked as final and can't be subclassed

Properties

Note:Do not change the visibility of these properties nor the declaration types.


templateEngine

The template engine used to render application views.

public string $templateEngine = 'default';

Available Template Engines

  1. default - To use default PHP template, no extra configuration required .
  2. smarty - To use smarty, Configurations: /app/Config/Templates/Smarty/Extensions.php.
  3. twig - To use twig, configurations: /app/Config/Templates/Twig/Extensions.php.

To use Smarty or Twig you will need to first install the library and configure the classes, constants or function to use manually.

Composer installation command:

Smarty: Install via Composer.

composer require smarty/smarty

Twig: Install via Composer.

composer require "twig/twig:^3.0

To learn more about Luminova Smarty or Twig extension see documentation.


templateIsolation

Controls whether templates run in isolation.

When isolation is enabled, the template can no longer use $this to access template options or view public properties and methods. This protects the application and view object and forces the template to use a safer, limited interface.

Instead of:

<?= $this->optionName;?>
<?= $this->app->appMethod();?>

you must use:

<?= $self->optionName;?>
<?= $self->app->appMethod();?>

The $self object exposes only the options and methods meant for the template.

public bool $templateIsolation = false;

Note:

This setting has no effect when using Smarty or Twig. Those engines already isolate variables in their own way.To access object in smarty or twig use {{ self.app }}


variablePrefixing

Controls whether options passed from controller to template should be prefixed with an underscore _ or not.

This property controls how to access the template scope options:

  • true → Variables use the _ prefix (e.g., $this->_optionName or $self->_optionName).
  • false → No prefix added (e.g., $this->optionName or $self->optionName).
  • null → Variables are stored as raw arrays ($options) (e.g, $options['optionName']).
public ?bool $variablePrefixing = true;

Note:This must be set before building your application.Changing it later will break template option recognition. Also avoid using self as option key name,


compileFolder

Directory by template engines for when compiling templates.

This property controls the template compile metadata directory. Use for template engines like Smarty or Twig.

public string $compileFolder = '/writeable/compile/';

configFolder

Directory for template engine configuration files.

This property controls the destination to store template configurations when using Smarty or Twig template engine.

public string $configFolder = '/writeable/config/';