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. [Framework](/categories/framework)
4. /
5. sfw2/render

ActiveLibrary[Framework](/categories/framework)

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

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

1.0.1(1y ago)0171AGPL-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 today

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 62% of packages

Maintenance40

Moderate activity, may be stable

Popularity7

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

511d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4603702?v=4)[Stefan Paproth](/maintainers/papparazzo)[@papparazzo](https://github.com/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

[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k39](/packages/neuron-core-neuron-ai)[cakephp/cakephp

The CakePHP framework

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

Bref is a framework to write and deploy serverless PHP applications on AWS Lambda.

3.4k10.6M67](/packages/bref-bref)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)

PHPackages © 2026

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