PHPackages                             mouf/html.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. mouf/html.renderer

ActiveLibrary[Templating &amp; Views](/categories/templating)

mouf/html.renderer
==================

This package contains the rendering mechanism of the Mouf framework. It is a mechanism allowing packages/templates/developers to overload a default template for various HTML objects.

v2.0.0(3y ago)0362.4k↓72.1%4[2 issues](https://github.com/thecodingmachine/html.renderer/issues)6MITPHPPHP ^8.0

Since Apr 17Pushed 3y ago12 watchersCompare

[ Source](https://github.com/thecodingmachine/html.renderer)[ Packagist](https://packagist.org/packages/mouf/html.renderer)[ Docs](http://mouf-php.com/packages/mouf/html.renderer)[ RSS](/packages/mouf-htmlrenderer/feed)WikiDiscussions 2.0 Synced today

READMEChangelog (4)Dependencies (22)Versions (14)Used By (6)

[![Latest Stable Version](https://camo.githubusercontent.com/4f3ed97578bb2f3fe4df40f5699f66aad085f743f70cf982d939a9e9b8c94733/68747470733a2f2f706f7365722e707567782e6f72672f6d6f75662f68746d6c2e72656e64657265722f762f737461626c652e737667)](https://packagist.org/packages/mouf/html.renderer)[![Total Downloads](https://camo.githubusercontent.com/41716edaad850e2bb07af1ae92928d97993f59f98bef365f2a923de6e7be1388/68747470733a2f2f706f7365722e707567782e6f72672f6d6f75662f68746d6c2e72656e64657265722f646f776e6c6f6164732e737667)](https://packagist.org/packages/mouf/html.renderer)[![Latest Unstable Version](https://camo.githubusercontent.com/99bfa7625044cc66d1473817c24f1a187bfa1ad27cea15ee1340f0e257b03780/68747470733a2f2f706f7365722e707567782e6f72672f6d6f75662f68746d6c2e72656e64657265722f762f756e737461626c65)](https://packagist.org/packages/mouf/html.renderer)[![License](https://camo.githubusercontent.com/b51fc468dbf8178f24340386152ba4875d9796d6ed52652c7a4fc30b37c7625b/68747470733a2f2f706f7365722e707567782e6f72672f6d6f75662f68746d6c2e72656e64657265722f6c6963656e7365)](https://packagist.org/packages/mouf/html.renderer)[![Build Status](https://camo.githubusercontent.com/f4d2d1d3fb8a702bff504f928ab9e15da68c9ea850865c7f7e04a312764bf34e/68747470733a2f2f7472617669732d63692e6f72672f746865636f64696e676d616368696e652f68746d6c2e72656e64657265722e7376673f6272616e63683d322e30)](https://travis-ci.org/thecodingmachine/html.renderer)[![Coverage Status](https://camo.githubusercontent.com/cebf333f580462455fc28a9476db1bf7ea77395694173c28d9cace0b60b3880d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f746865636f64696e676d616368696e652f68746d6c2e72656e64657265722f62616467652e7376673f6272616e63683d322e3026736572766963653d676974687562)](https://coveralls.io/github/thecodingmachine/html.renderer?branch=2.0)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/61ff8080e50e25d02b974809d57f6d556bd7a37f055d6ea502b7edea00e0e224/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f746865636f64696e676d616368696e652f68746d6c2e72656e64657265722f6261646765732f7175616c6974792d73636f72652e706e673f623d322e30)](https://scrutinizer-ci.com/g/thecodingmachine/html.renderer/?branch=2.0)

What is this package?
=====================

[](#what-is-this-package)

This package contains a rendering mechanism to **render objects in HTML**.

For application developers
--------------------------

[](#for-application-developers)

You are an application developer? [Learn how to use the rendering system](doc/for_application_developers.md) with PHP files or Twig templates to render your objects or overload renderers provided by packages.

See the video!

&lt;iframe width="480" height="360" src="//[www.youtube.com/embed/f2MyYSUic1U](http://www.youtube.com/embed/f2MyYSUic1U)" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt; For package developers
----------------------

[](#for-package-developers)

You are a package developer? [Learn how to use the rendering system to allow other users to overload your renderers easily.](doc/for_package_developers.md)

Installation
------------

[](#installation)

```
$ composer require mouf/html.renderer ^2
```

The easiest way to use this package is through a dependency injection container compatible with [container-interop/service-providers](https://github.com/container-interop/service-provider).

Once installed, you need to register the [`Mouf\Html\Renderer\RendererServiceProvider`](src/RendererServiceProvider.php) into your container.

If your container supports [thecodingmachine/discovery](https://github.com/thecodingmachine/discovery) integration, you have nothing to do. Otherwise, refer to your framework or container's documentation to learn how to register *service providers*.

### Provided services

[](#provided-services)

This *service provider* provides the following services:

Service nameDescription`RendererInterface::class`The default renderer. An alias to `ChainRenderer::class``ChainRenderer::class`A composite renderer asking all other renderers in turn if they can render an object.`customRenderers`A list of `RendererInterface` objects at the "custom" level (top most level). This list is consumed by the `ChainRenderer``customRenderer`A default custom renderer is provided by this package. Out of the box, template files are expected to be in the `src/templates` directory.`packageRenderers`A list of `RendererInterface` objects at the "package" level (bottom level). This list is consumed by the `ChainRenderer`. When a package you install has a renderer, it will add the renderer to this list (most of the time using the `AbstractPackageRendererServiceProvider``InitRendererFacadeMiddleware::class`A PSR-15 middleware that is used to initialize global access to the default renderer. This is needed for the `Renderable` trait to work.### Extended services

[](#extended-services)

This *service provider* extends those services:

NameCompulsoryDescription`MiddlewareListServiceProvider::MIDDLEWARES_QUEUE`*yes*The `InitRendererFacadeMiddleware::class` registers itself in the list of PSR-15 middlewares.Mouf package
------------

[](#mouf-package)

This package was originally part of Mouf (), an effort to ensure good developing practices by providing a graphical dependency injection framework.

V2 makes the package framework-agnostic, so it can be used in any framework.

Basically, you will find in this package some **Renderers**. These are classes in charge of rendering other objects. They usually rely on *template files*, that contain the HTML to be rendered. Renderers can be *chained*, and the first renderer that knows how to render an object will be in charge of the rendering.

Troubleshooting
---------------

[](#troubleshooting)

Your template or a custom template is not applied.

- Purge the cache with the red button in mouf.
- You use Ajax and you return html with echo (for example BCE).
    - By default an echo don't apply the template to make it
        - add the defaultRenderer (a class of Mouf\\Html\\Renderer\\AutoChainRenderer) in your class
        - add your templateRenderer (a class of Mouf\\Html\\Renderer\\FileBasedRenderer) in Bootstrap this is bootstrapRenderer
        - add the code before your call to the function toHTML: $this-&gt;defaultRenderer-&gt;setTemplateRenderer($this-&gt;templateRenderer);

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

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

###  Release Activity

Cadence

Every ~262 days

Recently: every ~473 days

Total

13

Last Release

1311d ago

Major Versions

v1.2.1 → v2.0.02022-12-01

PHP version history (2 changes)v1.0.0PHP &gt;=5.4.4

v2.0.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1104771?v=4)[mouf](/maintainers/mouf)[@Mouf](https://github.com/Mouf)

---

Top Contributors

[![moufmouf](https://avatars.githubusercontent.com/u/1290952?v=4)](https://github.com/moufmouf "moufmouf (69 commits)")[![nguyenk](https://avatars.githubusercontent.com/u/2227554?v=4)](https://github.com/nguyenk "nguyenk (3 commits)")[![xhuberty](https://avatars.githubusercontent.com/u/8350192?v=4)](https://github.com/xhuberty "xhuberty (2 commits)")[![homersimpsons](https://avatars.githubusercontent.com/u/16977446?v=4)](https://github.com/homersimpsons "homersimpsons (1 commits)")[![npeguin](https://avatars.githubusercontent.com/u/2227721?v=4)](https://github.com/npeguin "npeguin (1 commits)")

---

Tags

htmlinterfacerendertohtml

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mouf-htmlrenderer/health.svg)

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

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[cakephp/cakephp

The CakePHP framework

8.9k19.5M1.8k](/packages/cakephp-cakephp)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[getgrav/grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS

15.6k86.4k1](/packages/getgrav-grav)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[thecodingmachine/graphqlite

Write your GraphQL queries in simple to write controllers (using webonyx/graphql-php).

5733.3M47](/packages/thecodingmachine-graphqlite)

PHPackages © 2026

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