Download the PHP package alexandresalome/web-bundle without Composer
On this page you can find all versions of the php package alexandresalome/web-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alexandresalome/web-bundle
More information about alexandresalome/web-bundle
Files in alexandresalome/web-bundle
Package web-bundle
Short Description A bundle to make awesome web applications
License MIT
Informations about the package web-bundle
[DEPRECATED] AlexWebBundle
I recommend you to pick snippets in the code, but not to use it actually (very unstable).
Installation
Add alexandresalome/web-bundle to your composer.json:
{
"require": {
"alexandresalome/web-bundle": "dev-master"
}
}
Updates your dependencies and add it to your AppKernel:
public function registerBundles()
{
return array(
// ...
new Alex\WebBundle\AlexWebBundle()
)
}
Base controller
Controller
from this bundle provides a bunch of useful methods.
Take a look at the class for an exhaustive feature list.
Data Fixtures
namespace Acme\DemoBundle\DataFixtures\ORM;
use Alex\WebBundle\DataFixtures\ORMFixture;
use Doctrine\Common\Persistence\ObjectManager;
class UserData extends ORMFixture
{
public function load(ObjectManager $manager)
{
// access a container service
$this->get('security.encoder_factory');
}
}
Form templating
Twitter Bootstrap 3.0 templating is available in this bundle for forms. In Twig configuration, add form templating:
twig:
form:
resources: [ "AlexWebBundle::form_bootstrap3_layout.html.twig" ]
Locale listener
If you want to allow user to choose locale in a given set, you can turn
on the locale listener by appending in your config.yml
file:
alex_web:
locale_listener: [ fr_FR, en_US, pt_PT ]
This configuration will constraint the user locale on one of those. Default behavior is to store this locale in session. If you don't want to use session but still want to use the listener:
alex_web:
locale_listener:
enabled: true
locales: [fr_FR, en_US]
session_key: null # disable persistence in session
Twig extension :::::::::::::
|format_interval
Example:
Duration: {{ job.finishedAt.diff(jobStartedAt) }} {# should be job.duration #}
This method will transform DateInterval object to a string representation.
Pagination template ::::::::::::::::::
If you are using my pagination library,
you might appreciate the template AlexWebBundle::pagination.html.twig
. To use it:
{% embed "AlexWebBundle::pagination.html.twig" %}
{% block colspan '3' %}
{% block head %}
<th>Username</th>
<th>Fullname</th>
<th>Actions</th>
{% endblock %}
{% block body %}
{% for user in pager %}
<tr>
{# ... #}
</tr>
{% else %}
<tr><td colspan="{{ block('colspan') }}"><em>no user</em></td></tr>
{% endfor %}
{% endblock %}
{% endembed %}
Form extra widgets :::::::::::::::::
Form sections
Structure your form with sections. Sections will group fields with a legend above, so that your form is more structured:
$builder
->add($builder->create('informations' 'form_section')
->add('firstname', 'text')
->add('lastname', 'text')
)
->add($builder->create('contacts', 'form_section')
->add('main', 'contact')
)
Form tabs
Here is an example of a form with tabs:
$builder = $this->get('form.factory')->createBuilder('form_tabs');
$builder
->add($builder->create('informations', 'form_tab')
->add('firstname', 'text')
->add('lastname', 'text')
)
->add($builder->create('contacts', 'form_tab')
->add('main', 'contact')
)
;