PHPackages                             sfw2/render - 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. sfw2/render

ActiveLibrary

sfw2/render
===========

simple redering library for rendering response content on conditions (Content negotiation)

1.0.1(1y ago)0151AGPL-3.0-or-laterPHPPHP ^8.3

Since Feb 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/papparazzo/sfw2-render)[ Packagist](https://packagist.org/packages/sfw2/render)[ RSS](/packages/sfw2-render/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (3)Used By (1)

sfw2-render
===========

[](#sfw2-render)

Enables redering web-content on condition (see [https://developer.mozilla.org/en-US/docs/Web/HTTP/Content\_negotiation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation) for further information)

How to use it
-------------

[](#how-to-use-it)

First, set up a render-object and specify the conditions:

```
use Handlebars\Handlebars;
use SFW2\Render\Conditions\IsAjaxRequest;
use SFW2\Render\Conditions\MatchesPath;
use SFW2\Render\RenderJson;
use SFW2\Render\RenderOnConditions;

// Have a look at salesforce/handlebars-php for the proper use
$handlebars = new Handlebars([
    "loader" => StringLoader(),
]);

$render = new RenderOnConditions();

// Checks, if "X-Requested-With" header line is set and, if so, render data in json-format
$render->addEngine(new IsAjaxRequest(), new RenderJson());

// Checks, if certain request-path is set and, if so, render data in xml-format.
$render->addEngine(new MatchesPath('/'), new RenderJson($handlebars));

// Render other stuff in html-format
$render->addEngine(new AlwaysTrue(),  new RenderHtml($handlebars, '{{content}}'));
```

use the prebuild render in your controller/action-class to render your response-content on the previous declared conditions

```
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use SFW2\Render\RenderInterface;

class MyController{

    public function __construct(
        private RenderInterface $render
    ) {
    }

    public function myAction(RequestInterface $request, ResponseInterface $response, array $data): ResponseInterface
    {
        return $this->render->render($request, $response, [], 'mytemplate.handlebars');
    }
}
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance43

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 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 ~0 days

Total

2

Last Release

464d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7ea6d5fa84340a33e81568df1b6572c05b0d590d0dd6ca0222a75d6d4b5a3a7d?d=identicon)[papparazzo](/maintainers/papparazzo)

---

Top Contributors

[![papparazzo](https://avatars.githubusercontent.com/u/4603702?v=4)](https://github.com/papparazzo "papparazzo (14 commits)")

---

Tags

micro-frameworksfw2

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sfw2-render/health.svg)

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

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[chubbyphp/chubbyphp-framework

A minimal, highly performant middleware PSR-15 microframework built with as little complexity as possible, aimed primarily at those developers who want to understand all the vendors they use.

13544.4k4](/packages/chubbyphp-chubbyphp-framework)[php-heroku-client/php-heroku-client

A PHP client for the Heroku Platform API

24404.8k4](/packages/php-heroku-client-php-heroku-client)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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