A simple AJAX form login for Symfony 2., (*1)
Prerequisites
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
., (*2)
Installation
Step 1: Download AjaxLoginBundle using composer
In your composer.json, add AjaxLoginBundle :, (*3)
{
"require": {
"divi/ajax-login-bundle": "dev-master"
}
}
Now, you must update your vendors using this command :, (*4)
``` bash
$ php composer.phar update divi/ajax-login-bundle, (*5)
### Step 2: Enable the bundle
Enable the bundle using the AppKernel :
``` php
<?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", (*6)
``` yaml, (*7)
app/config/security.yml
security:
firewalls:
main:
pattern: ^/
ajax_form_login:
# ..., (*8)
## How to use
### Examples
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](https://github.com/FriendsOfSymfony/FOSUserBundle) form login.
If you want to use the javascript part on your login twig form, just include the init file :
``` twig
{% include 'DiviAjaxLoginBundle:Javascript:init.html.twig' with {'form_selector': '#your_form_id'} %}
Issue or new feature ?
Feel free to post your issue or feature request in the issue tracker !, (*9)