PHPackages                             vanio/vanio-web-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. [Framework](/categories/framework)
4. /
5. vanio/vanio-web-bundle

ActiveSymfony-bundle[Framework](/categories/framework)

vanio/vanio-web-bundle
======================

Symfony2 Bundle providing some additional features for website development

v0.4.0(7y ago)08.4k1[2 PRs](https://github.com/vaniocz/vanio-web-bundle/pulls)1MITPHPPHP ^7.0CI failing

Since Jun 17Pushed 3y ago7 watchersCompare

[ Source](https://github.com/vaniocz/vanio-web-bundle)[ Packagist](https://packagist.org/packages/vanio/vanio-web-bundle)[ Docs](https://github.com/vaniocz/vanio-web-bundle)[ RSS](/packages/vanio-vanio-web-bundle/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (13)Versions (49)Used By (1)

[![Vanio](https://camo.githubusercontent.com/b691445be273912a0905be759555aa166528db3a3606ddf1f25a54e734e7efbb/687474703a2f2f7777772e76616e696f2e637a2f696d672f76616e696f2d6c6f676f2e706e67)](http://www.vanio.cz) Web Bundle
============================================================================================================================================================================================================================

[](#-web-bundle)

[![Build Status](https://camo.githubusercontent.com/6377b550819b4b1df3b23be2c50dd2cd1bca83b00e966759310b226be3bdea45/68747470733a2f2f7472617669732d63692e6f72672f76616e696f637a2f76616e696f2d7765622d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vaniocz/vanio-web-bundle)[![Coverage Status](https://camo.githubusercontent.com/af554f855bef4bc64dd604d01993bed3d5f8571a432410f68fc2da0c0d0e0a74/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f76616e696f637a2f76616e696f2d7765622d62756e646c652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/vaniocz/vanio-web-bundle?branch=master)[![PHP7](https://camo.githubusercontent.com/1707d1cf35d1b3dba207caa68b99d5e4af7689d1c4bf5ad784bf4b1ec532f507/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372d3642374542392e737667)](https://camo.githubusercontent.com/1707d1cf35d1b3dba207caa68b99d5e4af7689d1c4bf5ad784bf4b1ec532f507/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372d3642374542392e737667)[![License](https://camo.githubusercontent.com/45530b1c555c9166eeaa95d90c2314c5975321da04c690d4e4e274939bd70adc/68747470733a2f2f706f7365722e707567782e6f72672f76616e696f2f76616e696f2d7765622d62756e646c652f6c6963656e7365)](https://github.com/vaniocz/vanio-web-bundle/blob/master/LICENSE)

Installation
============

[](#installation)

Installation can be done as usually using composer. `composer require vanio/vanio-web-bundle`

Next step is to register this bundle as well as bundles it depends on inside your `AppKernel`.

```
// app/AppKernel.php
// ...

class AppKernel extends Kernel
{
    // ...

    public function registerBundles(): array
    {
        $bundles = [
            // ...
            new Vanio\UserBundle\VanioWebBundle,
        ];

        // ...
    }
}
```

Features
========

[](#features)

Detecting request type
----------------------

[](#detecting-request-type)

To detect whether current request is master or sub request, special request attribute `_request_type` is set. This logic happens inside `Vanio\WebBundle\Request\RequestTypeListener` listener which is not registered by default. Enable this feature by setting `detect_request_type` configuration parameter to true.

Redirecting to Referer
----------------------

[](#redirecting-to-referer)

It's quite a common task to redirect user back after certain actions. This bundle defines a service named `vanio_web.request.referer_resolver` which helps you with that. First it tries to read from `_referer` (`%vanio_web.referer_parameter%`) query parameter. When the query parameter is not present then it reads HTTP\_REFERER header and tries to match the referring URL against defined routes. In case of missing header or invalid URL (like URL pointing to a different webpage) fallback path is used. Since this functionality is mostly used from inside controllers, it is possible to use `Vanio\WebBundle\Request\RefererHelperTrait`which defines one method - `redirectToReferer(string $fallbackPath = null): RedirectResponse`.

Flash Messages
--------------

[](#flash-messages)

Another thing which seems too complicated to me is translating of flash messages. It's actually very easy but you need a session and a translator. Two dependencies just to show a translated flash message. To simplify that there is `Vanio\WebBundle\Translation\FlashMessage` value object you can use as an envelope of the message and pass the message parameters and domain to it. This bundle also replaces `translation.extractor.php`service with implementation able to extract messages from `FlashMessage` constructor.

```
$this->addFlash(FlashMessage::TYPE_DANGER, new FlashMessage('message', ['key' => 'value'], 'vanio_web'));
```

But adding a flash message is just half of the problem. You'll also need to display it somewhere in your view and actually translate it yourself.

Validation of required fields
-----------------------------

[](#validation-of-required-fields)

The `required` option normally affects only the HTML5 `required` attribute. This bundle allows setting of `validate_required: true` to automatically add a `NotBlank` constraint to the form. The default validation message is configurable by setting `required_message`.

Form state URL canonization
---------------------------

[](#form-state-url-canonization)

Due to SEO optimizations and also in situations where having full form state serialized in URL is too long and ugly it is possible to set `canonize: true` in form options. When you submit the form it is then redirected to canonical URL where all empty form fields (even those equal to `empty_data` option) are ommited.

Templating
----------

[](#templating)

### Generating class name

[](#generating-class-name)

Sometimes, even just generating a class name of HTML elements can be cumbersome when it depends on some conditions. Let's use `class_name(array $classes): string` Twig function. You need to pass it an array where key is a class and value is a boolean value indicating whether this class name should be present.

### Checking whether a text is translated

[](#checking-whether-a-text-is-translated)

To check whether text is translated you can use `is_translated(string $id, string $locale = null)` Twig function which checks translator's catalogue. The text is considered as translated when it is present in the catalogue and the translation does not equal to false.

### Determining current menu item

[](#determining-current-menu-item)

To determine whether a current request matches a menu item, use `is_current(string $route): bool` Twig function. The route is considered current when either `_route` request attribute equals to the given route or when request pathinfo starts with the route path and it's delimited by `/`.

### Testing whether a given object implements a given type

[](#testing-whether-a-given-object-implements-a-given-type)

In Twig, there is no possibility how to determine whether a given object implements a given type. So, for example, it is not possible to determine whether a flash message is just a string or an instance of the added `FlashMessage` class. And that's why `instance of(string $class)` Twig test was added. You can use it like this:

```
{{ message is instance of('Vanio\\WebBundle\\Translation\\FlashMessage')
    ? message.message|trans(message.parameters, message.domain, message.locale)
    : message }}
```

### Removing values from arrays

[](#removing-values-from-arrays)

Removing certain values from an array is possible using `without(array $array, $values)` Twig filter. Pass it either a value or an array of values to remove and it will return a new array with the given values being unset.

```
{{ ['foo', 'bar']|without('foo') }}
```

### Removing keys from arrays

[](#removing-keys-from-arrays)

Removing certain keys from an array is possible using `without(array $array, $keys)` Twig filter. Pass it either a string or an array of keys to remove and it will return a new array with the given keys being unset.

```
{{ {foo: 'bar', bar: 'baz'}|without_keys('foo') }}
```

### Removing empty values from arrays

[](#removing-empty-values-from-arrays)

Removing empty values from an array is possible using `withoutEmpty(array $array)` Twig filter. Value is considered empty using the same implementation as `empty` Twig test (`''`, `false`, `null`, `[]`, or instances of `Countable` with zero length).

```
{{ [null, 1]|without_empty }}
```

### Replacing based on regular expressions

[](#replacing-based-on-regular-expressions)

The builtin `replace` Twig filter uses `strtr` under the hood but there is no support for replacing based on regular expressions. So we've implemented `regexp_replace(string $string, $pattern, $replacement)` filter. You can pass it either an array with keys as regular expressions and values as replacements or when the replacement argument is provided then the pattern can be either a string or an array (keys are ignored).

```
{{ 'foo bar'|regexp_replace({'~foo~': 'baz', '~bar~': 'qux'}) }}
{{ 'foo'|regexp_replace('~foo~', 'bar') }}
{{ 'foo bar'|regexp_replace(['~foo~', '~bar~'], 'baz') }}
```

### Converting HTML to plaintext

[](#converting-html-to-plaintext)

Have you ever created an HTML e-mail? Providing plaintext alternative manually is tedious so `html_to_text(string $html, array $options = []): string` Twig filter is your friend in such cases. It uses handy [html2text](https://github.com/mtibben/html2text) library.

Default Configuration
=====================

[](#default-configuration)

```
detect_request_type: false
referer_fallback_path: /
referer_parameter: _referer
```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 86.1% 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 ~161 days

Total

4

Last Release

2821d ago

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/83fd24874418acb2e635bc408732703403e16fea6c003224f1e066f07e239bcb?d=identicon)[stanleyk](/maintainers/stanleyk)

---

Top Contributors

[![maryo](https://avatars.githubusercontent.com/u/900769?v=4)](https://github.com/maryo "maryo (254 commits)")[![dvondrak](https://avatars.githubusercontent.com/u/11498368?v=4)](https://github.com/dvondrak "dvondrak (35 commits)")[![stanleyk](https://avatars.githubusercontent.com/u/510199?v=4)](https://github.com/stanleyk "stanleyk (5 commits)")[![mlazovla](https://avatars.githubusercontent.com/u/2652944?v=4)](https://github.com/mlazovla "mlazovla (1 commits)")

---

Tags

web

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vanio-vanio-web-bundle/health.svg)

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[oro/platform

Business Application Platform (BAP)

645143.5k115](/packages/oro-platform)[chameleon-system/chameleon-base

The Chameleon System core.

1028.6k5](/packages/chameleon-system-chameleon-base)[contao/core-bundle

Contao Open Source CMS

1231.6M2.8k](/packages/contao-core-bundle)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M508](/packages/pimcore-pimcore)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M203](/packages/sulu-sulu)

PHPackages © 2026

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