Loading...
 
Twig is a modern template engine for PHP

Twig Template Engine

Twig is a modern template engine for PHP1

Twig is used by many Open-Source projects like Symfony, Drupal, eZPublish, phpBB, Matomo, OroCRM; and many frameworks have support for it as well like Slim, Yii, Laravel, and Codeigniter.2

Table of contents

Resources

Debug

The dump function dumps information about a template variable.3
The dump function is not available by default. You must add the \Twig\Extension\DebugExtension extension explicitly when creating your Twig environment:

$twig = new \Twig\Environment($loader, [
    'debug' => true,
    // ...
]);
$twig->addExtension(new \Twig\Extension\DebugExtension());

Even when enabled, the dump function won’t display anything if the debug option on the environment is not enabled (to avoid leaking debug information on a production server).4

<pre>
    {{ dump(user) }}
</pre>
  • Using a pre tag is not needed when XDebug is enabled and html_errors is on; as a bonus, the output is also nicer with XDebug enabled.


Last edited by MichaelAlber .
Page last modified on Thursday July 16, 2020 17:27:23 UTC.

Books

Linux Command Line and Shell Scripting Bible Linux Command Line and Shell Scripting Bible - Linux Command Line and Shell Scripting Bible is your essential Linux guide. With detailed instruction and abundant examples, this book teaches you how to bypass the graphical interface and communicate directly with your computer, saving time and expanding capability.


Linux Bible Linux Bible - Linux continues to be an excellent, low-cost alternative to expensive operating systems. Whether you're new to Linux or need a reliable update and reference, this is an excellent resource. Veteran bestselling author Christopher Negus provides a complete tutorial packed with major updates, revisions, and hands-on exercises so that you can confidently start using Linux today.


Learning Python Learning Python - Portable, powerful, and a breeze to use, Python is the popular open source object-oriented programming language used for both standalone programs and scripting applications.


Modern PHP: New Features and Good Practices Modern PHP: New Features and Good Practices - PHP is experiencing a renaissance, though it may be difficult to tell with all of the outdated PHP tutorials online. With this practical guide, you'll learn how PHP has become a full-featured, mature language with object-orientation, namespaces, and a growing collection of reusable component libraries.