PHPackages                             joomla/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. [Framework](/categories/framework)
4. /
5. joomla/renderer

ActiveJoomla-package[Framework](/categories/framework)

joomla/renderer
===============

Joomla Renderer Package

3.0.1(10mo ago)622.9k4[2 issues](https://github.com/joomla-framework/renderer/issues)1LGPL-2.1-or-laterPHPPHP ^8.1.0CI passing

Since Jun 5Pushed 5mo ago8 watchersCompare

[ Source](https://github.com/joomla-framework/renderer)[ Packagist](https://packagist.org/packages/joomla/renderer)[ Docs](https://github.com/joomla-framework/renderer)[ RSS](/packages/joomla-renderer/feed)WikiDiscussions 3.x-dev Synced 1mo ago

READMEChangelog (3)Dependencies (12)Versions (9)Used By (1)

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)

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 "~3.0"
```

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance58

Moderate activity, may be stable

Popularity31

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 68.1% 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.

###  Release Activity

Cadence

Every ~467 days

Total

5

Last Release

303d ago

Major Versions

2.0.1 → 3.0.02023-10-08

PHP version history (3 changes)2.0.0-betaPHP ^7.2.5

2.0.1PHP ^7.2.5|~8.0.0|~8.1.0

3.0.0PHP ^8.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/305a2164440014dcef9ac681c139fe5e8a1ce1d7a8c3b3cfb828497729a4c70e?d=identicon)[wilsonge](/maintainers/wilsonge)

---

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 (26 commits)")[![nibra](https://avatars.githubusercontent.com/u/827605?v=4)](https://github.com/nibra "nibra (9 commits)")[![wilsonge](https://avatars.githubusercontent.com/u/1986000?v=4)](https://github.com/wilsonge "wilsonge (8 commits)")[![heelc29](https://avatars.githubusercontent.com/u/66922325?v=4)](https://github.com/heelc29 "heelc29 (3 commits)")[![joomla-jenkins](https://avatars.githubusercontent.com/u/929228?v=4)](https://github.com/joomla-jenkins "joomla-jenkins (2 commits)")[![photodude](https://avatars.githubusercontent.com/u/10253980?v=4)](https://github.com/photodude "photodude (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)")[![richard67](https://avatars.githubusercontent.com/u/7413183?v=4)](https://github.com/richard67 "richard67 (1 commits)")

---

Tags

bladejoomlajoomla-frameworkmustachephpplatestemplatingtwigframeworkrendererjoomla

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[slim/php-view

Render PHP view scripts into a PSR-7 Response object.

2739.7M95](/packages/slim-php-view)[windwalker/renderer

Windwalker Renderer package

864.9M25](/packages/windwalker-renderer)[joomla/filter

Joomla Filter Package

151.4M8](/packages/joomla-filter)[joomla/application

Joomla Application Package

23404.8k11](/packages/joomla-application)[joomla/registry

Joomla Registry Package

16468.6k20](/packages/joomla-registry)[joomla/filesystem

Joomla Filesystem Package

12369.7k7](/packages/joomla-filesystem)

PHPackages © 2026

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