A simple AJAX form login for Symfony 2.
This version of the bundle requires Symfony > 2.1
. If you have the version 2.0
or 2.1
, please switch to the branch 2.0-2.1
.
In your composer.json, add AjaxLoginBundle :
{
"require": {
"divi/ajax-login-bundle": "dev-master"
}
}
Now, you must update your vendors using this command :
$ php composer.phar update divi/ajax-login-bundle
Enable the bundle using the AppKernel :
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Divi\AjaxLoginBundle\DiviAjaxLoginBundle(),
);
}
Configure your form login using security.yml, replace "form_login" authentication by "ajax_form_login"
# app/config/security.yml
security:
firewalls:
main:
pattern: ^/
ajax_form_login:
# ...
Two examples are available in the Resources/views/Login
folder. Note: jQuery is required for these two examples. If not exists, it will be loaded dynamically (with Google API).
The first example works with the AcmeBundle (Symfony standard) form login, the second with the FOSUserBundle form login.
If you want to use the javascript part on your login twig form, just include the init file :
{% include 'DiviAjaxLoginBundle:Javascript:init.html.twig' with {'form_selector': '#your_form_id'} %}
Feel free to post your issue or feature request in the issue tracker !