2. Installation

2.1. Download SmartyBundle

This can be done in several ways, depending on your preference. The first method is the standard Symfony2.1 method.

2.1.1. Symfony 2.1.x — Composer

Add SmartyBundle in your composer.json‘:

{
    "require": {
        "noiselabs/smarty-bundle": "dev-master"
    }
}

Now tell composer to download the bundle by running the command:

$ php composer.phar update noiselabs/smarty-bundle

Composer will install the bundle to your project’s vendor/noiselabs directory.

2.1.2. Symfony 2.0.x — Using the vendors script

Add the following lines in your deps file:

[SmartyBundle]
    git=git://github.com/noiselabs/SmartyBundle.git
    target=bundles/NoiseLabs/Bundle/SmartyBundle

Now, run the vendors script to download the bundle:

$ php bin/vendors install

2.1.3. Using submodules

If you prefer instead to use git submodules, then run the following:

$ git submodule add git://github.com/noiselabs/SmartyBundle.git vendor/bundles/NoiseLabs/Bundle/SmartyBundle
$ git submodule update --init

2.2. Configure the Autoloader (only if not using composer!)

Add the NoiseLabs namespace to your autoloader:

// app/autoload.php

$loader->registerNamespaces(array(
    // ...
    'NoiseLabs\\Bundle' => __DIR__.'/../vendor/bundles',
));

2.3. Enable the bundle

Enable the bundle in the kernel:

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new NoiseLabs\Bundle\SmartyBundle\SmartyBundle(),
    );
}

2.4. Enable the Smarty template engine in the config

  • YAML
    # app/config/config.yml
    # ...
    framework:
        templating:      { engines: ['twig', 'smarty'] }