PHPackages                             brazilianfriendsofsymfony/twig-extensions-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. brazilianfriendsofsymfony/twig-extensions-bundle

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

brazilianfriendsofsymfony/twig-extensions-bundle
================================================

Symfony BFOSTwigExtensionsBundle

1.0.x-dev(13y ago)342.8k↓100%4[1 issues](https://github.com/BrazilianFriendsOfSymfony/BFOSTwigExtensionsBundle/issues)MITPHPPHP &gt;=5.3.2

Since Jul 31Pushed 9y ago3 watchersCompare

[ Source](https://github.com/BrazilianFriendsOfSymfony/BFOSTwigExtensionsBundle)[ Packagist](https://packagist.org/packages/brazilianfriendsofsymfony/twig-extensions-bundle)[ Docs](http://www.duocriativa.com.br/bfos)[ RSS](/packages/brazilianfriendsofsymfony-twig-extensions-bundle/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (6)Versions (2)Used By (0)

The BFOSTwigExtensionsBundle
============================

[](#the-bfostwigextensionsbundle)

This bundle provides the following *Twig filters*:

- `bfos_format_bytes`: Format the number in bytes into a human readable format.
- `bfos_align_right`: Format a string: right-justification with spaces. Useful using the pre html tag.
- `bfos_align_left`: Format a string: left-justification with spaces. Useful using the pre html tag.

and provides the following *Form types*:

- `bfos_richtextarea`: bfos\_richtextarea type to allow you use rich text form fields out of the box. Currently uses CkEditor.

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

[](#installation)

You need to install de submodule on the deps file::

```
// deps
[BFOSTwigExtensionsBundle]
    git=git://github.com/BrazilianFriendsOfSymfony/BFOSTwigExtensionsBundle.git
    target=/bundles/BFOS/TwigExtensionsBundle

```

And then::

```
bash$ php bin/vendors install

```

Configuration
-------------

[](#configuration)

Add this to app/autoload.php::

```
// app/autoload.php
$loader->registerNamespaces(array(
  // ...
  'BFOS'              => __DIR__.'/../vendor/bundles',
  // ...
));

```

And this to app/AppKernel.php::

```
// app/AppKernel.php
$bundles = array(
  // ...
  new BFOS\TwigExtensionsBundle\BFOSTwigExtensionsBundle(),
  // ...
);

```

Add the following to your config.yml

```
twig:
    form:
        resources:
            - 'BFOSTwigExtensionsBundle:Form:form_div_layout.html.twig'

```

Usage
-----

[](#usage)

[Test Form Widgets Screenshot](blob/master/Resources/doc/images/test-form-widgets.png)

How to use::

- FCBKComplete Entity widget:

Setup your Type:

```
public function buildForm(FormBuilder $builder, array $options)
{
    $url = $this->container->get('router')->generate('users_autocomplete');
    $builder->add('users', 'bfos_fcbkcomplete_entity',
        array('class'=>'FOS\UserBundle\Entity\User', 'url'=>$url, 'fcbkcomplete_options'=>array('maxitems'=>40, 'maxshownitems'=>40)));
}

```

Setup your action for auto complete list:

```
/**
 * Auto completer list action.
 *
 * @Route("/users/autocomplete", name="users_autocomplete")
 * @Method("get")
 */
public function usersAutoCompleteAction(){
    if(!($q = $this->getRequest()->get('tag'))){
        return new \Symfony\Component\HttpFoundation\Response('');
    }

    $arr = array();
    $users = $this->getDoctrine()->getRepository('FOSUserBundle:User')->findForAutoComplete($q);
    foreach($users as $user){
        $arr[] = array('key'=> (string) $user->getId(), 'value'=> sprintf('%s (%s)', $user->getUsername(), $user->getEmail())) ;
    }
    return new \Symfony\Component\HttpFoundation\Response(json_encode($arr), 200, array('Content-Type'=> 'application/json'));
}

```

Setup a repository method:

```
public function findForAutoComplete($string, $limit = 20){
    if(!$string){
        return array();
    }

    $qb = $this->createQueryBuilder('u');
    $query = $qb->where('u.username LIKE :str')->orWhere('u.email LIKE :str')->setParameter('str', "%$string%")->getQuery();
    return $query->setMaxResults($limit)->getResult();
}

```

- Date Picker widget:

Setup your Type:

```
public function buildForm(FormBuilder $builder, array $options)
{
    $builder->add('date', 'bfos_date');
}

```

Warning: The widget does not support the option widget set to single\_text.

- DateTime Picker widget:

Setup your Type:

```
public function buildForm(FormBuilder $builder, array $options)
{
    $builder->add('date', 'bfos_datetime');
}

```

Warning: The widget does not support the option widget set to single\_text.

- Filter `bfos_format_bytes`::

    {{ \[integer\] | bfos\_format\_bytes }}

You can also specify which base is to be used (SI or Binary)::

```
{# Default. SI #}
{{ [integer] | bfos_format_bytes( true ) }}
{# Use the binary #}
{{ [integer] | bfos_format_bytes( false )  }}

```

- Filter `bfos_align_right` and `bfos_align_left`

    {# Default. Use 10 columns to justify. #} {{ \[string\] | bfos\_align\_right }} {# Justify using the space of 20 columns. #} {{ \[string\] | bfos\_align\_right(20) }}

    {# Default. Use 10 columns to justify. #} {{ \[string\] | bfos\_align\_left }} {# Justify using the space of 20 columns. #} {{ \[string\] | bfos\_align\_left(20) }}

*EXAMPLE:*

The following code

```

{% set sizes = [0, 27, 999, 1000, 1023, 1024, 1728, 110592, 7077888, 452984832, 28991029248, 1855425871872, 9223372036854775807] %}
{{ "Size in bytes"|bfos_align_left(20) }}   {{ "SI"|bfos_align_right(15)}} {{ "Binary"|bfos_align_right(15)}}
{% for i in sizes %}
{{ i|bfos_align_left(20) }} = {{ i|bfos_format_bytes|bfos_align_right(15) }} {{ i|bfos_format_bytes(false)|bfos_align_right(15) }}
{% endfor %}

```

will produce the following result

```
Size in bytes                       SI          Binary
0                    =             0 B             0 B
27                   =            27 B            27 B
999                  =           999 B           999 B
1000                 =          1000 B          1000 B
1023                 =          1.0 kB          1023 B
1024                 =          1.0 kB          1024 B
1728                 =          1.7 kB         1.7 KiB
110592               =        110.6 kB       108.0 KiB
7077888              =          7.1 MB         6.8 MiB
452984832            =        453.0 MB       432.0 MiB
28991029248          =         29.0 GB        27.0 GiB
1855425871872        =          1.9 TB         1.7 TiB
9.2233720368548E+18  =          9.2 EB         8.0 EiB

```

###  Health Score

27

—

LowBetter than 51% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.7% 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

Unknown

Total

1

Last Release

4984d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4645a858774b4a24783e1a27b05b9ddae1fc9e86c651e1592d9aa4769e390917?d=identicon)[ribeiro.paulor](/maintainers/ribeiro.paulor)

---

Top Contributors

[![ribeiropaulor](https://avatars.githubusercontent.com/u/376830?v=4)](https://github.com/ribeiropaulor "ribeiropaulor (54 commits)")[![jcchavezs](https://avatars.githubusercontent.com/u/3075074?v=4)](https://github.com/jcchavezs "jcchavezs (3 commits)")

---

Tags

twig extensions

### Embed Badge

![Health badge](/badges/brazilianfriendsofsymfony-twig-extensions-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/brazilianfriendsofsymfony-twig-extensions-bundle/health.svg)](https://phpackages.com/packages/brazilianfriendsofsymfony-twig-extensions-bundle)
```

###  Alternatives

[endroid/qr-code-bundle

Endroid QR Code Bundle

32110.3M13](/packages/endroid-qr-code-bundle)[sonata-project/twig-extensions

Sonata twig extensions

9110.6M18](/packages/sonata-project-twig-extensions)[egeloen/ordered-form-bundle

Provides a form ordering support for your Symfony2 project.

49573.3k1](/packages/egeloen-ordered-form-bundle)[pug-php/pug-symfony

Pug template engine for Symfony

444.4k](/packages/pug-php-pug-symfony)[damianociarla/rating-bundle

This Bundle provides functionality for a rating system for Symfony applications

236.1k](/packages/damianociarla-rating-bundle)

PHPackages © 2026

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