wearejust/user-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.

Small wrapper for sonata user packages

Installs: 4 697

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 1

Open Issues: 0

Type:symfony-bundle

1.0.3 2019-10-21 08:00 UTC

This package is auto-updated.

Last update: 2023-03-19 22:20:16 UTC


README

This package is basically a small wrapper around Sonata User bundle

Installation

Hint: Coming from 0.x? Please check out our upgrade guide

Step 1: Download the Bundle

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.

Step 2: Enable the Bundle

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(),
        );

        // ...
    }

    // ...
}

Step 3: Define your User/Group Entity

// 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;
}

Step 4: Configure

// 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