PHPackages                             chiron/php-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. chiron/php-renderer

AbandonedArchivedLibrary[Framework](/categories/framework)

chiron/php-renderer
===================

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

1.9.2(5y ago)071[2 issues](https://github.com/ncou/Chiron-PhpRenderer/issues)1MITPHPPHP ^7.1

Since Apr 2Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ncou/Chiron-PhpRenderer)[ Packagist](https://packagist.org/packages/chiron/php-renderer)[ GitHub Sponsors](https://github.com/ncou)[ RSS](/packages/chiron-php-renderer/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (4)Versions (17)Used By (1)

[![Build Status](https://camo.githubusercontent.com/b887d71c144e6bde6beccfacf157f10ea1297ebafe866c90034732fabc8fbc1f/68747470733a2f2f7472617669732d63692e6f72672f6e636f752f436869726f6e2d50687052656e64657265722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ncou/Chiron-PhpRenderer)[![Coverage Status](https://camo.githubusercontent.com/958662f877c83aadebe2edd92148d595fb8982a35b7acab8a0e706d57d74a2bf/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6e636f752f436869726f6e2d50687052656e64657265722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/ncou/Chiron-PhpRenderer?branch=master)[![CodeCov](https://camo.githubusercontent.com/22acb23f841522f6c794fb0aad438ca7d2ee457ab0a56077ac8a607e5bee253a/68747470733a2f2f636f6465636f762e696f2f67682f6e636f752f436869726f6e2d50687052656e64657265722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/ncou/Chiron-PhpRenderer)

[![Total Downloads](https://camo.githubusercontent.com/ae31c548ec7fc6851a927f01a0a55991f84300872987753efca86de42e794d35/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636869726f6e2f7068702d72656e64657265722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chiron/php-renderer/stats)[![Monthly Downloads](https://camo.githubusercontent.com/82abd0972335d8c20986c95cc970eb57b28e5895881b0e14cd68be47b1fb8bcd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f636869726f6e2f7068702d72656e64657265722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chiron/php-renderer/stats)

[![StyleCI](https://camo.githubusercontent.com/0318802d693c40bfccf95de297ee237ba0ed8a014f4eadec19a649a5e9942661/68747470733a2f2f7374796c6563692e696f2f7265706f732f3132373735323739362f736869656c643f7374796c653d666c6174)](https://styleci.io/repos/127752796)[![PHP-Eye](https://camo.githubusercontent.com/fb817fe5c167b48f91763f6616029cc33da6bda3cb8925bbf0420c33711ab5e7/68747470733a2f2f7068702d6579652e636f6d2f62616467652f636869726f6e2f7068702d72656e64657265722f7465737465642e7376673f7374796c653d666c6174)](https://php-eye.com/package/chiron/php-renderer)[![PHPStan](https://camo.githubusercontent.com/441b5874ce4df0a2defc892979c96c46889b69cb32119d04f0b48626349f8bc9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/phpstan/phpstan)

PHP Renderer
------------

[](#php-renderer)

This is a renderer for rendering PHP view scripts into a PSR-7 Response object. It works well with Chiron Framework.

### Cross-site scripting (XSS) risks

[](#cross-site-scripting-xss-risks)

Note that PHP-View has no built-in mitigation from XSS attacks. It is the developer's responsibility to use `htmlspecialchars()` or a component like [zend-escaper](https://github.com/zendframework/zend-escaper). Alternatively, consider [Twig-View](https://github.com/slimphp/Twig-View).

Templates
---------

[](#templates)

You may use `$this` inside your php templates. `$this` will be the actual PhpRenderer object will allow you to render sub-templates

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

[](#installation)

Install with [Composer](http://getcomposer.org):

```
composer require chiron/php-renderer

```

Usage with Chiron
-----------------

[](#usage-with-chiron)

```
use Chiron\Views\PhpRenderer;

include "vendor/autoload.php";

$app = new Chiron\App();
$container = $app->getContainer();
$container['renderer'] = new PhpRenderer("./templates");

$app->get('/hello/{name}', function ($request, $response, $args) use ($container) {
    $text = $container->get('renderer')->render("/hello.php", $args);
    return $response->write($text);
});

$app->run();
```

Usage with any PSR-7 Project
----------------------------

[](#usage-with-any-psr-7-project)

```
//Construct the View
$phpView = new PhpRenderer("./path/to/templates");

//Render a Template
$text = $phpView->render("/path/to/template.php", $yourData);
$response = $response->write($text);
```

Template Variables
------------------

[](#template-variables)

You can now add variables to your renderer that will be available to all templates you render.

```
// via the constructor
$templateVariables = [
    "title" => "Title"
];
$phpView = new PhpRenderer("./path/to/templates", $templateVariables);

// or setter
$phpView->setAttributes($templateVariables);

// or individually
$phpView->addAttribute($key, $value);
```

Data passed in via `->render()` takes precedence over attributes.

```
$templateVariables = [
    "title" => "Title"
];
$phpView = new PhpRenderer("./path/to/templates", $templateVariables);

//...

$phpView->render($template, [
    "title" => "My Title"
]);
// In the view above, the $title will be "My Title" and not "Title"
```

Exceptions
----------

[](#exceptions)

`\RuntimeException` - if template does not exist

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~61 days

Recently: every ~17 days

Total

15

Last Release

2152d ago

Major Versions

0.3 → 1.02018-09-03

PHP version history (2 changes)1.0PHP &gt;=7.1.3

1.3PHP ^7.1

### Community

Maintainers

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

---

Top Contributors

[![ncou](https://avatars.githubusercontent.com/u/16743322?v=4)](https://github.com/ncou "ncou (71 commits)")

---

Tags

phpframeworktemplateviewrendererphtmlchiron

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M19.5k](/packages/laravel-framework)[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[slim/php-view

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

2849.9M101](/packages/slim-php-view)[htmlburger/wpemerge

A micro framework which modernizes WordPress as a CMS development by providing tools to implement MVC and more.

456139.8k8](/packages/htmlburger-wpemerge)[rubellum/slim-blade-view

Slim Framework 3 view helper built on the Blade component

1822.4k2](/packages/rubellum-slim-blade-view)[hiropeke/slim-blade-view

Slim Framework 3 view helper built on the Blade component

182.0k1](/packages/hiropeke-slim-blade-view)

PHPackages © 2026

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