Download the PHP package chh/meta-template without Composer

On this page you can find all versions of the php package chh/meta-template. 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 meta-template

MetaTemplate

A library which provides adapters to different PHP templating engines

Install

MetaTemplate follows the PSR-0 standard for class loading, so its classes can be loaded with every compliant autoloader, such as Zend_Loader or the Symfony Classloader.

Installation is easy, just register the MetaTemplate namespace with your autoloader and point it to the directory where you copied the contents of the lib directory to.

Basic Usage

Most of the time you will be consuming engines via the Template class. It provides some methods, which take a filename and return a template instance.

MetaTemplate ships with these adapters/engines by default:

The MetaTemplate\Template class has a static create method, which creates template instances from a given path.

For example:

<?php

use MetaTemplate\Template;

$template = Template::create('/path/to/foo.phtml');
echo get_class($template);
// => "\MetaTemplate\Template\PHPTemplate"

All templates implement the \MetaTemplate\Template\TemplateInterface, which provides a render method which, you probably guessed it, returns the rendered contents.

The render method takes two arguments, which are both optional:

  1. $context: The template's context, in most engines this is what $this inside the template script refers to.
  2. $locals: A array, which defines the local variables available in the template script.

These two arguments allow to inject the data into the template script.

If the templating engine does not have to support contexts or locals, these two arguments are simply ignored. This is the case with the Markdown and Less engines.

Digging one layer deeper

If want to setup all engine mappings up by yourself and have no default setup of Engines, then the MetaTemplate\Util\EngineRegistry is for you.

This class simply provides the instance behind the static methods of the MetaTemplate\Template class.

To map a template class to one or more file extensions, just call the register method the same way you would on the Template class:

$registry = new \MetaTemplate\Util\EngineRegistry;
$registry->register('\\MetaTemplate\\Template\\LessTemplate', 'less');

You can then use the create method to create new Template instances for the provided path.

Writing your own engines

As previously noted, all templating engines need to implement the MetaTemplate\Template\TemplateInterface. Though, there is the MetaTemplate\Template\Base class, which you can inherit from, which handles some redundant aspects, such as template data loading.

The Base class defines a prepare method, which lets you hook into the template initialization. This method is called before the constructor returns.

Your template's content is loaded into the $data property.

Look at the supplied templating engines, if you need some examples.


All versions of meta-template with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.6
chh/fileutils Version 1.0.*@dev
symfony/process Version ~2.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 chh/meta-template contains the following files

Loading the files please wait ...