PHPackages                             mvrhov/view-bundle - 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. mvrhov/view-bundle

ActiveSymfony-bundle[Templating &amp; Views](/categories/templating)

mvrhov/view-bundle
==================

mvrhov view bundle

119PHP

Since Dec 27Pushed 8y ago1 watchersCompare

[ Source](https://github.com/mvrhov/mvrhovViewBundle)[ Packagist](https://packagist.org/packages/mvrhov/view-bundle)[ RSS](/packages/mvrhov-view-bundle/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

### View bundle for Symfony

[](#view-bundle-for-symfony)

This bundle adds two View classes that you can return from your controller's action `RouteView`, `TemplateView` and an interface `ResponderInterface` which the class you are returning from the controller should implement.

### Installation

[](#installation)

1. Require View bundle as a dependency using Composer:

    ```
    php composer.phar require mvrhov/view-bundle

    ```
2. Add bundle to `app/AppKernel.php`

    ```
       public function registerBundles()
       {
           return array(
               new \mvrhov\ViewBundle\mvrhovViewBundle();
               // ...
           );
       }
    ```
3. You are done.

### Examples

[](#examples)

RouteView
---------

[](#routeview)

```
use mvrhov\ViewBundle\View\RouteView;
use mvrhov\ViewBundle\View\ViewInterface;

final class RouteAction
{
    public function __invoke(): ViewInterface
    {
        $params = [
            'param1' => 'view',
            'param2' => 'bundle',
        ];

        return new RouteView('my_route', $params);
    }
}
```

TemplateView
------------

[](#templateview)

```
use mvrhov\ViewBundle\View\TemplateView;
use mvrhov\ViewBundle\View\ViewInterface;

final class TemplateAction
{
    public function __invoke(): ViewInterface
    {
        $data = [
            'foo' => 1,
            'bar' => 'yep'
        ];

        return new TemplateView('@Bundle/template.html.twig', $data);
    }
}
```

Responder
---------

[](#responder)

```
use mvrhov\ViewBundle\View\ResponderInterface;
use mvrhov\ViewBundle\View\TemplateView;
use mvrhov\ViewBundle\View\RouteView;
use mvrhov\ViewBundle\View\ResponseView;

final class InvoiceResponder implements ResponderInterface;
{
    private $invoices;

    public function __construct(array $invoices)
    {
        $this->invoices = $invoices;
    }

    public function getView(Request $request, int $requestType): ViewInterface
    {
        if ('application/json' !== $request->getContentType()) {
            $total = count($this->invoices);

            if (0 === $total) {
                return new RouteView('list_invoices');
            }

            if (1 === $total) {
                return new TemplateView('@Bundle/template_one.html.twig', $this->invoices);
            }

            if (5 > $total) {
                return new TemplateView('@Bundle/template_a_lot.html.twig', $this->invoices);
            }
        } else {
            return new ResponseView(new Response(json_serialize($this->invoices)));
        }
    }
}

use mvrhov\ViewBundle\View\TemplateView;
use mvrhov\ViewBundle\View\ResponderInterface;

final class ResponderAction
{
    public function __invoke(): ResponderInterface
    {
        $invoices = $this->getInvoices();

        return new InvoiceResponder($invoices);
    }
}
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c03ca79334f04d59814ba1ff794c6582bffa24c5c8b733748fb3d0faec18965b?d=identicon)[mvrhov](/maintainers/mvrhov)

---

Top Contributors

[![mvrhov](https://avatars.githubusercontent.com/u/450008?v=4)](https://github.com/mvrhov "mvrhov (5 commits)")

---

Tags

php7symfonysymfony-bundleview

### Embed Badge

![Health badge](/badges/mvrhov-view-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/mvrhov-view-bundle/health.svg)](https://phpackages.com/packages/mvrhov-view-bundle)
```

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

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