Download the PHP package webiny/template-engine without Composer

On this page you can find all versions of the php package webiny/template-engine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package template-engine

Template Engine Component

TemplateEngine component provides a layer for rendering view templates.

Install the component

The best way to install the component is using Composer.

For additional versions of the package, visit the Packagist page.

Installation error

If you get an error like this:

Then probably you don't have Subversion installed which is preventing the installation of Smarty library. This can be easily solved by installing the Subversion, prior to the composer install.

$ sudo apt-get install subversion

Usage

The definition of the view template depends on the selected driver. By default the template engine comes with a driver for Smarty, but you can easily add support for Twig or some other template engines.

The provided functionality of every driver is defined by the TemplateEngineInterface which defines the following methods:

To create a new driver just create a new class that implements the \Webiny\Component\TemplateEngine\Bridge\TemplateEngineInterface and adapt your config.

The default configuration looks like this:

Usage

The preferred usage is over the TemplateEngineTrait. Here is an example:

Smarty

If you wish to use the Smarty template engine, with the built in driver, make sure you include path/to/Smarty/libs/Smarty.class.php somewhere inside you application, before using the component. This is due to the problem that Smarty doesn't provide a suitable autoloader to be integrated with the component.

Plugins & extensions

The template engine is designed so that it can be expanded with different plugins and modifiers, depending on the assigned driver.

Best practice for expanding the template engine is first to create an extension and then register it as a service tagged with the $driverName.Extension, for example Smarty.Extension.

An Extension is a package of one or multiple plugins. Plugin type depends on the template engine, for example, Smarty supports these plugin types:

To create a smarty extension, create a class that extends \Webiny\Component\TemplateEngine\Drivers\Smarty\AbstractSmartyExtension and then overwrite the methods, based on the plugin type your wish to create.

For example, let's say we want to register a modifier called 'customUpper'. First we create our extension class like this:

Once we have our extension, we must register it using the service manager:

And that's it, we can now use the modifier in our templates:

Resources

To run unit tests, you need to use the following command:

$ cd path/to/Webiny/Component/TemplateEngine/
$ composer.phar install
$ phpunit

All versions of template-engine with dependencies

PHP Build Version
Package Version
Requires php Version ^7
webiny/config Version ~1.6
webiny/std-lib Version ~1.6
webiny/service-manager Version ~1.6
smarty/smarty Version 3.1.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package webiny/template-engine contains the following files

Loading the files please wait ....