PHPackages                             babdev/renderer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. babdev/renderer

Abandoned → [joomla/renderer](/?search=joomla%2Frenderer)ArchivedJoomla-package[Templating &amp; Views](/categories/templating)

babdev/renderer
===============

Joomla Renderer Package

61634[2 issues](https://github.com/BabDev/renderer/issues)PHPCI passing

Since Jan 1Pushed 3w ago8 watchersCompare

[ Source](https://github.com/BabDev/renderer)[ Packagist](https://packagist.org/packages/babdev/renderer)[ RSS](/packages/babdev-renderer/feed)WikiDiscussions 4.x-dev Synced 3d ago

READMEChangelog (3)DependenciesVersions (1)Used By (0)

EOL
===

[](#eol)

This packages is no longer maintained and archived. No replacement by the Joomla Project is planned.

The Renderer Package [![Build Status](https://github.com/joomla-framework/renderer/actions/workflows/ci.yml/badge.svg?branch=3.x-dev)](https://github.com/joomla-framework/renderer)
====================================================================================================================================================================================

[](#the-renderer-package-)

[![Latest Stable Version](https://camo.githubusercontent.com/a3cd12d05d4d57eebaa5fc4bb432705ed9a330823d1a3850bd0efd79fa6483e6/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6f6d6c612f72656e64657265722f762f737461626c65)](https://packagist.org/packages/joomla/renderer)[![Total Downloads](https://camo.githubusercontent.com/392061a523448163610e8af45372614bdb16cd180bf530ddadede938915a936c/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6f6d6c612f72656e64657265722f646f776e6c6f616473)](https://packagist.org/packages/joomla/renderer)[![Latest Unstable Version](https://camo.githubusercontent.com/419061657976f07735ee47658fafe272d2637d4a182bc2c19a73004350389761/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6f6d6c612f72656e64657265722f762f756e737461626c65)](https://packagist.org/packages/joomla/renderer)[![License](https://camo.githubusercontent.com/c45f3f49c2c1c64c0c9f77d85c4c894dc49e76f586be66ae4faa637ec2ae8907/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6f6d6c612f72656e64657265722f6c6963656e7365)](https://packagist.org/packages/joomla/renderer)

Deprecated
----------

[](#deprecated)

The joomla/renderer package has been deprecated. No further updates are planned.

Interfaces
----------

[](#interfaces)

### `Renderer\RendererInterface`

[](#rendererrendererinterface)

`Renderer\RendererInterface` is an interface to provide a common rendering API.

Classes
-------

[](#classes)

- `Renderer\MustacheRenderer`
- `Renderer\PhpEngineRenderer`
- `Renderer\PlatesRenderer`
- `Renderer\TwigRenderer`

All classes except `PlatesRenderer` extend the parent rendering engine classes to enable those engines to implement the `RendererInterface`.

##### Usage

[](#usage)

`Renderer\RendererInterface` classes can be instantiated in the same manner as their parent implementations, please refer to the vendor documentation for further details.

To assist with using these classes, example service providers are shared in this repository's [samples](/samples) folder, as well as the sample configuration which these providers are dependent upon.

###### Example Use Case

[](#example-use-case)

An example use of the `Renderer\RendererInterface` is provided here. In this example, our controller class builds a view class based on `Joomla\View\ViewInterface` and injects the required dependencies.

Sample Controller:

```
namespace Joomla\Controller;

use Joomla\Renderer\RendererInterface;

use Joomla\Controller\AbstractController;
use Joomla\DI\ContainerAwareInterface;
use Joomla\DI\ContainerAwareTrait;
use Joomla\View\ViewInterface;

/**
 * Default controller class for the application
 *
 * @since  1.0
 */
class DefaultController extends AbstractController implements ContainerAwareInterface
{
	use ContainerAwareTrait;

	/**
	 * The default view for the application
	 *
	 * @var    string
	 * @since  1.0
	 */
	protected $defaultView = 'dashboard';

	/**
	 * State object to inject into the model
	 *
	 * @var    \Joomla\Registry\Registry
	 * @since  1.0
	 */
	protected $modelState = null;

	/**
	 * Execute the controller
	 *
	 * This is a generic method to execute and render a view and is not suitable for tasks
	 *
	 * @return  boolean  True if controller finished execution
	 *
	 * @since   1.0
	 * @throws  \RuntimeException
	 */
	public function execute()
	{
		try
		{
			// Initialize the view object
			$view = $this->initializeView();

			// Render our view.
			$this->getApplication()->setBody($view->render());

			return true;
		}
		catch (\Exception $e)
		{
			throw new \RuntimeException(sprintf('Error: ' . $e->getMessage()), $e->getCode());
		}
	}

	/**
	 * Method to initialize the model object
	 *
	 * @return  \Joomla\Model\ModelInterface
	 *
	 * @since   1.0
	 * @throws  \RuntimeException
	 */
	protected function initializeModel()
	{
		$model = '\\Joomla\\Model\\' . ucfirst($this->getInput()->getWord('view')) . 'Model';

		// If a model doesn't exist for our view, revert to the default model
		if (!class_exists($model))
		{
			$model = '\\Joomla\\Model\\DefaultModel';

			// If there still isn't a class, panic.
			if (!class_exists($model))
			{
				throw new \RuntimeException(sprintf('No model found for view %s', $vName), 500);
			}
		}

		return new $model($this->modelState);
	}

	/**
	 * Method to initialize the renderer object
	 *
	 * @return  RendererInterface  Renderer object
	 *
	 * @since   1.0
	 * @throws  \RuntimeException
	 */
	protected function initializeRenderer()
	{
		$type = $this->getContainer()->get('config')->get('template.renderer');

		// Set the class name for the renderer's service provider
		$class = '\\Joomla\\Service\\' . ucfirst($type) . 'RendererProvider';

		// Sanity check
		if (!class_exists($class))
		{
			throw new \RuntimeException(sprintf('Renderer provider for renderer type %s not found.', ucfirst($type)));
		}

		// Add the provider to the DI container
		$this->getContainer()->registerServiceProvider(new $class);

		return $this->getContainer()->get('renderer');
	}

	/**
	 * Method to initialize the view object
	 *
	 * @return  ViewInterface  View object
	 *
	 * @since   1.0
	 * @throws  \RuntimeException
	 */
	protected function initializeView()
	{
		// Initialize the model object
		$model = $this->initializeModel();

		$view   = ucfirst($this->getInput()->getWord('view', $this->defaultView));

		$class = '\\Joomla\\View\\' . $view . 'HtmlView';

		// Ensure the class exists, fall back to default otherwise
		if (!class_exists($class))
		{
			$class = '\\Joomla\\View\\DefaultHtmlView';

			// If we still have nothing, abort mission
			if (!class_exists($class))
			{
				throw new \RuntimeException(sprintf('A view class was not found for the %s view.', $view));
			}
		}

		// HTML views require a renderer object too, fetch it
		$renderer = $this->initializeRenderer();

		// Instantiate the view now
		/* @type  \Joomla\View\AbstractHtmlView  $object */
		$object = new $class($model, $renderer);

		// We need to set the layout too
		$object->setLayout(strtolower($view) . '.' . strtolower($this->getInput()->getWord('layout', 'index')));

		return $object;
	}
}
```

The view class in this example is extended from this sample class which extends `\Joomla\View\AbstractView`:

```
namespace Joomla\View;

use Joomla\Renderer\RendererInterface;

use Joomla\Model\ModelInterface;
use Joomla\View\AbstractView;

/**
 * Abstract HTML View class
 *
 * @since  1.0
 */
abstract class AbstractHtmlView extends AbstractView
{
	/**
	 * The data array to pass to the renderer engine
	 *
	 * @var    array
	 * @since  1.0
	 */
	private $data = array();

	/**
	 * The name of the layout to render
	 *
	 * @var    string
	 * @since  1.0
	 */
	private $layout;

	/**
	 * The renderer object
	 *
	 * @var    RendererInterface
	 * @since  1.0
	 */
	private $renderer;

	/**
	 * Class constructor
	 *
	 * @param   ModelInterface     $model     The model object.
	 * @param   RendererInterface  $renderer  The renderer object.
	 *
	 * @since   1.0
	 */
	public function __construct(ModelInterface $model, RendererInterface $renderer)
	{
		parent::__construct($model);

		$this->setRenderer($renderer);
	}

	/**
	 * Retrieves the data array
	 *
	 * @return  array
	 *
	 * @since   1.0
	 */
	public function getData()
	{
		return $this->data;
	}

	/**
	 * Retrieves the layout name
	 *
	 * @return  string
	 *
	 * @since   1.0
	 * @throws  \RuntimeException
	 */
	public function getLayout()
	{
		if (is_null($this->layout))
		{
			throw new \RuntimeException('The layout name is not set.');
		}

		return $this->layout;
	}

	/**
	 * Retrieves the renderer object
	 *
	 * @return  RendererInterface
	 *
	 * @since   1.0
	 */
	public function getRenderer()
	{
		return $this->renderer;
	}

	/**
	 * Method to render the view.
	 *
	 * @return  string  The rendered view.
	 *
	 * @since   1.0
	 * @throws  \RuntimeException
	 */
	public function render()
	{
		return $this->getRenderer()->render($this->getLayout(), $this->getData());
	}

	/**
	 * Sets the data array
	 *
	 * @param   array  $data  The data array.
	 *
	 * @return  $this  Method allows chaining
	 *
	 * @since   1.0
	 */
	public function setData(array $data)
	{
		$this->data = $data;

		return $this;
	}

	/**
	 * Sets the layout name
	 *
	 * @param   string  $layout  The layout name.
	 *
	 * @return  $this  Method allows chaining
	 *
	 * @since   1.0
	 */
	public function setLayout($layout)
	{
		$this->layout = $layout;

		return $this;
	}

	/**
	 * Sets the renderer object
	 *
	 * @param   RendererInterface  $renderer  The renderer object.
	 *
	 * @return  $this  Method allows chaining
	 *
	 * @since   1.0
	 */
	public function setRenderer(RendererInterface $renderer)
	{
		$this->renderer = $renderer;

		return $this;
	}
}
```

The view class for our view as established in the above sample controller:

```
namespace Joomla\View;

use Joomla\Model\DefaultModel;

/**
 * HTML view class for the Dashboard
 *
 * @since  1.0
 */
class DashboardHtmlView extends AbstractHtmlView
{
	/**
	 * Redeclared model object for proper typehinting
	 *
	 * @var    DefaultModel
	 * @since  1.0
	 */
	protected $model;

	/**
	 * Method to render the view.
	 *
	 * @return  string  The rendered view.
	 *
	 * @since   1.0
	 */
	public function render()
	{
		$this->setData(['data' => $this->model->getData()]);

		return parent::render();
	}
}
```

Installation via Composer
-------------------------

[](#installation-via-composer)

You can simply run the following from the command line:

```
composer require joomla/renderer "~4.0"
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance56

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 62.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/52468993b62b781c3c94028d5626d35fd53297482813af84db6e96e81ae67283?d=identicon)[mbabker](/maintainers/mbabker)

---

Top Contributors

[![mbabker](https://avatars.githubusercontent.com/u/368545?v=4)](https://github.com/mbabker "mbabker (113 commits)")[![Hackwar](https://avatars.githubusercontent.com/u/313866?v=4)](https://github.com/Hackwar "Hackwar (37 commits)")[![wilsonge](https://avatars.githubusercontent.com/u/1986000?v=4)](https://github.com/wilsonge "wilsonge (10 commits)")[![nibra](https://avatars.githubusercontent.com/u/827605?v=4)](https://github.com/nibra "nibra (9 commits)")[![heelc29](https://avatars.githubusercontent.com/u/66922325?v=4)](https://github.com/heelc29 "heelc29 (3 commits)")[![photodude](https://avatars.githubusercontent.com/u/10253980?v=4)](https://github.com/photodude "photodude (2 commits)")[![joomla-jenkins](https://avatars.githubusercontent.com/u/929228?v=4)](https://github.com/joomla-jenkins "joomla-jenkins (2 commits)")[![richard67](https://avatars.githubusercontent.com/u/7413183?v=4)](https://github.com/richard67 "richard67 (2 commits)")[![PhilETaylor](https://avatars.githubusercontent.com/u/400092?v=4)](https://github.com/PhilETaylor "PhilETaylor (1 commits)")[![piotr-cz](https://avatars.githubusercontent.com/u/612953?v=4)](https://github.com/piotr-cz "piotr-cz (1 commits)")

---

Tags

bladejoomlajoomla-frameworkmustachephpplatestemplatingtwig

### Embed Badge

![Health badge](/badges/babdev-renderer/health.svg)

```
[![Health](https://phpackages.com/badges/babdev-renderer/health.svg)](https://phpackages.com/packages/babdev-renderer)
```

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
