Skip to content

Documentation for PHP developers

mochja edited this page Feb 13, 2013 · 5 revisions

RainTPL 3 require PHP > 5.3 to run. The best way to install RainTPL is with Composer, but you can also download it and run one example.

Install RainTPL

  1. Install composer https://github.com/composer/composer

  2. Create a composer.json inside your application folder:

    {
        "require": {
            "rain/raintpl": ">=3.0.0"
        }
    }
  3. Open the command line and run the following:

    $ php composer.phar install
  4. Now create an index.php file and require the autoload.php of Composer:

    <?php
    require "vendor/autoload.php";
  1. Use the RainTPL name space:
    use Rain\Tpl;
  1. Configure RainTPL:
    $config = array(
                     "tpl_dir"       => "vendor/rain/raintpl/templates/test/",
                     "cache_dir"     => "vendor/rain/raintpl/cache/"
    );
    Tpl::configure( $config );
  1. Init, assign and draw the template:
    $t = new Tpl;
    $t->assign('title','Hello!');
    $t->draw('test');