General-purpose view helpers for PHP templating engine from Chillout Development.

Installs: 1 145

Dependents: 1

Stars: 3

Watchers: 2

Forks: 1

Type: symfony-bundle


ChillDevViewHelpersBundle is a Symfony2 bundle that brings set of useful view helpers for PHP templating engine.

Build Status Scrutinizer Quality Score Coverage Status Dependency Status SensioLabsInsight

Because not everyone uses Twig…


This bundle is provided as Composer package. To install it simply add following dependency definition to your composer.json file:

"chilldev/view-helpers-bundle": "dev-master"

Replace dev-master with different constraint if you want to use specific version.

Note: This bundle requires PHP 5.4.


All you need to do in order to use this bundle's goods is to load it in your kernel:


use ChillDev\Bundle\ViewHelpersBundle\ChillDevViewHelpersBundle;

use Symfony\Component\HttpKernel\Kernel as BaseKernel;

class Kernel extends BaseKernel
    public function registerBundles()
        $bundles = [
            new ChillDevViewHelpersBundle(),

Of course there are some optional configuration options.


Major feature of this bundle is set of common (X)HTML tag helpers like <meta>, <link> etc. Here is sample usage:

In your view file:

<?php $view->extend('::layout.html.php'); ?>

<?php $view['title']->append($page->getName()); ?>
<?php $view['meta']->getMetaName('keywords')->append($page->getKeywords()); ?>
<?php $view['meta']->setMetaName('description', \strip_tags($page->getDescription())); ?>
<?php $view['meta']->setProperty('og:title', $page->getName()); ?>
<?php $view['link']->add('', 'next'); ?>
<?php $view['script']->add('/javascript/prototype.js'); ?>
<?php $view['xmlns'][''] = ''; ?>
<?php $view['xmlns'][''] = 'hx'; ?>
<?php $view['xmlns'][''] = 'og'; ?>
<?php $view['xmlns'][''] = 'fb'; ?>

<p><?php echo $view['truncate']->truncate($text, 255); ?></p>

In your layout file:

<!DOCTYPE html>
<html<?php echo $view['xmlns']; ?>>
        <?php echo $view['title']; ?>
        <?php echo $view['meta']; ?>
        <?php echo $view['link']; ?>
        <?php echo $view['script']; ?>
        <?php $view['slots']->output('_content') ?>

For more advanced aspects see advanced usage documentation or even internals description.


There are also some extra resources included in this bundle that can be useful for your PHP-templates-based project.

KnpPaginatorBundle supports PHP templating, but lacks default template for paginator helper. You can use one from this bundle with just following one setting in your application configuration:

# KNP paginator configuration
        pagination: "ChillDevViewHelpersBundle:Pagination:sliding.html.php"

Another additional enchantment to PHP templating engine provided by this bundle is possibility to define global templating variables. This feature is available out of the box for Twig templating engine in Symfony (with TwigBundle), but there is no equivalent for native PHP templates. Now, with our bundle you can do:

            slogan: "The best page ever!"
            sms: "your.sms.service"

And use it directly in templates:

<h1><?php echo $slogan; ?></h1>
<p><?php echo $sms->getGatewayNumber(); ?></p>



Do you want to help improving this project? Simply fork it and post a pull request. You can do everything on your own, you don't need to ask if you can, just do all the awesome things you want!

This project is published under MIT license.


ChillDevViewHelpersBundle is brought to you by Chillout Development.

List of contributors: