This package is basically a small wrapper around Sonata User bundle
Hint: Coming from 0.x? Please check out our upgrade guide
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require wearejust/user-bundle "^1.0"
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Wearejust\UserBundle\WearejustUserBundle(),
);
// ...
}
// ...
}
// User
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Sonata\UserBundle\Entity\BaseUser;
/**
* @ORM\Entity
* @ORM\Table(name="fos_user_user")
*/
class User extends BaseUser
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
}
// Group
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Sonata\UserBundle\Entity\BaseGroup;
/**
* @ORM\Entity
* @ORM\Table(name="fos_user_group")
*/
class Group extends BaseGroup
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
}
// config.yml
fos_user:
db_driver: orm
firewall_name: main
user_class: 'Path\To\Custom\User\Entity'
group:
group_class: 'Path\To\Custom\Group\Entity'
group_manager: sonata.user.orm.group_manager
service:
user_manager: sonata.user.orm.user_manager
from_email:
address: "%mailer_user%"
sender_name: "%mailer_user%"
sonata_user:
class:
user: 'Path\To\Custom\User\Entity'
group: 'Path\To\Custom\Group\Entity'
admin:
user:
class: Wearejust\UserBundle\Admin\UserAdmin
group:
class: Wearejust\UserBundle\Admin\GroupAdmin
impersonating:
route: sonata_admin_dashboard