Download the PHP package reestyle/templateerphp without Composer

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

TemplateerPHP

Installation

Either download the files or use composer to install.

$ composer require reestyle/templateerphp

Usage

FYI

Templates can be anywhere relative to the folder set with setBaseDir. Going outside that scope is possible (there is no limitation), but then you'd need to remember or guess the folder path down to the double dot (..). Templates must end with .phtml.

As a form of 'protection', templates are loaded inside in a lambda function. Thus the TemplateerPHP class' private and protected properties and methods are invisible to the template. You can only access the public methods of the class.


'Controller' code

Basic usage when calling templates:

    $templateer = new TemplateerPHP();

    $data = array_merge($this->data, [
        'pageTitle' => 'Hello Page!',
        'content' => 'Hello World!',
    ]);

    $viewHelpers = [
        'UrlHelper',
        'PageContentHelper',
    ]
    foreach ($viewHelpers as $helper) {
        $templateer->addHelper($helper);
    }

    $templateer
        ->setLayout('layout/default')
        ->setBaseDir(__DIR__)
        ->assign($data);

    $html = $templateer
        ->setImplicitLayout(true)
        ->render($this->getResource(), false);

Helpers

A template helper is registered by its 'lowercased' name. E.g. PageContentHelper would become pagecontenthelper.

A helper should contain the magic method __invoke(). In the template you can address them like:

<?=pagecontenthelper() ?>

You can return whatever you'd like from __invoke(). Here also is no limitation.


Template code

Use shorthands in templates.

Basic template:

   <h1><?=$pageTitle?></h1>

   <div id="content"><?=$content?></div>

Would produce:

   <h1>Hello Page!</h1>

   <div id="content">Hello world!</div>

Partials / inserts

Using partials (or inserts) is easy too:

   <?=$templateer->partial('[template]', ['var1' => 'val1']); ?>

You don't need to add .phtml. The partial renderer assumes it.

The partial may look like this:

   <?=$var1; ?>

To output something like this:

   val1

License

The Unlicense. Free to use, alter, distribute, even make money, either personal or commercial.

See LICENSE file for specifics. Or don't... You may use it in any way you want anyway.


All versions of templateerphp with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
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 reestyle/templateerphp contains the following files

Loading the files please wait ...