2017 © Pedro Peláez
 

symfony-bundle sonata-sylius-user-bundle

Symfony bundle providing a bridge between SonataAdmin and SyliusUser (an alternative to SonataUserBundle)

image

libre-informatique/sonata-sylius-user-bundle

Symfony bundle providing a bridge between SonataAdmin and SyliusUser (an alternative to SonataUserBundle)

  • Friday, March 16, 2018
  • by beta
  • Repository
  • 5 Watchers
  • 3 Stars
  • 3,073 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 12 Versions
  • 0 % Grown

The README.md

Sonata Sylius User Bundle

Travis [Coveralls][coveralls] License, (*1)

Latest Stable Version Latest Unstable Version Total Downloads, (*2)

This is a Symfony bundle providing a bridge between SonataAdmin and SyliusUser (an alternative to SonataUserBundle)., (*3)

The idea behind this bundle was to have user management in Sonata Admin without using FOSUserBundle (which was not stable enough by the time we started this project)., (*4)

Sylius already had a good user management component and bundle, we just filled the gap..., (*5)

Installation

We assume you're familiar with Composer, a dependency manager for PHP. Use the following command to add the bundle to your composer.json and download the package., (*6)

If you have Composer installed globally, (*7)

$ composer require libre-informatique/sonata-sylius-user-bundle

Otherwise you have to download .phar file., (*8)

$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar require libre-informatique/sonata-sylius-user-bundle

Adding required bundles to the kernel

You need to enable the bundle inside the kernel., (*9)

If you're not using any other Sylius bundles, you will also need to add SyliusUserBundle and its dependencies to kernel. Don't worry, everything was automatically installed via Composer., (*10)

<?php

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // SYLIUS USER BUNDLE AND DEPENDENCIES
        new FOS\RestBundle\FOSRestBundle(),
        new JMS\SerializerBundle\JMSSerializerBundle($this),
        new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
        new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
        new Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle(),
        new winzou\Bundle\StateMachineBundle\winzouStateMachineBundle(),
        // Sylius Bundles have to be declared before DoctrineBundle
        new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
        new Sylius\Bundle\MailerBundle\SyliusMailerBundle(),
        new Sylius\Bundle\UserBundle\SyliusUserBundle(),

        // OTHER BUNDLES...
        new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
        // [...]

        // SONATA SYLIUS USER BUNDLE
        new Librinfo\SonataSyliusUserBundle\SonataSyliusUserBundle(),
    );
}

Note: Please register SyliusUserBundle before DoctrineBundle. This is important as it uses listeners which have to be processed first., (*11)

Configure Doctrine extensions

Configure doctrine extensions which are used by the bundle., (*12)

# app/config/config.yml
stof_doctrine_extensions:
    orm:
        default:
            timestampable: true

Update database schema

Run the following command., (*13)

$ php bin/console doctrine:schema:update --force

Warning: This should be done only in dev environment! We recommend using Doctrine migrations, to safely update your schema., (*14)

Congratulations! The bundle is now installed and ready to be configured. :boom:, (*15)

Configure routes and security

In this chapter, we assume your Sonata Admin routes are prefixed with /admin., (*16)

Import SonataSyliusUserBundle security routes (for login, lougout an login_check):, (*17)

# app/config/routing.yml

# Security routing for SyliusUserBundle
# (defines login, logout and login_check routes)
sonata_sylius_user_security:
    resource: "@SonataSyliusUserBundle/Resources/config/routing/security.yml"
    prefix: /admin

Configure your application security (this is an example):, (*18)

# app/config/security.yml

security:

    encoders:
        Sylius\Component\User\Model\UserInterface: sha512

    providers:
        sonata_user_provider:
            id: sylius.sonata_user_provider.email_or_name_based

    firewalls:
        # disables authentication for assets and the profiler, adapt it according to your needs
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        sonata:
            switch_user: true
            context: sonata
            pattern: /admin(?:/.*)?$
            form_login:
                provider: sonata_user_provider
                login_path: sonata_sylius_user_login
                check_path: sonata_sylius_user_login_check
                failure_path: sonata_sylius_user_login
                default_target_path: sonata_admin_dashboard
                use_forward: false
                use_referer: true
            logout:
                path: sonata_sylius_user_logout
                target: sonata_sylius_user_login
            anonymous: true

    access_control:
        - { path: ^/(css|images|js), role: IS_AUTHENTICATED_ANONYMOUSLY } # allow assets for anonymous users
        - { path: ^/admin/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } # allow resetting password for anonymous users
        - { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/login-check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: "^/admin.*", role: ROLE_ADMINISTRATION_ACCESS }

Configure Sylius User Bundle

SonataSyliusUserBundle provides a configuration file that you can import in your application configuration :, (*19)

# app/config/config.yml

imports:
    - { resource: "@SonataSyliusUserBundle/Resources/config/app/config.yml" }

If you want to use your own configuration for SyliusUserBundle (classes, repositoties, templates, etc), then you will have to adapt this config.yml to your needs instead of importing it., (*20)

The Versions

16/03 2018

dev-wip-platform

dev-wip-platform https://github.com/sil-project/SonataSyliusUserBundle

Symfony bundle providing a bridge between SonataAdmin and SyliusUser (an alternative to SonataUserBundle)

  Sources   Download

LGPL-3.0 LGPL-3.0-only

The Requires

 

The Development Requires

by Marcos Bezerra de Menezes

symfony sylius sonata admin

15/11 2017

dev-wip-lisem

dev-wip-lisem https://github.com/libre-informatique/SonataSyliusUserBundle

Symfony bundle providing a bridge between SonataAdmin and SyliusUser (an alternative to SonataUserBundle)

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Marcos Bezerra de Menezes

symfony sylius sonata admin

03/11 2017

dev-master

9999999-dev https://github.com/libre-informatique/SonataSyliusUserBundle

Symfony bundle providing a bridge between SonataAdmin and SyliusUser (an alternative to SonataUserBundle)

  Sources   Download

GPL-3.0 LGPL-3.0

The Requires

 

The Development Requires

by Marcos Bezerra de Menezes

symfony sylius sonata admin

03/11 2017

0.6.4

0.6.4.0 https://github.com/libre-informatique/SonataSyliusUserBundle

Symfony bundle providing a bridge between SonataAdmin and SyliusUser (an alternative to SonataUserBundle)

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Marcos Bezerra de Menezes

symfony sylius sonata admin

19/10 2017

0.5.2

0.5.2.0 https://github.com/libre-informatique/SonataSyliusUserBundle

Symfony bundle providing a bridge between SonataAdmin and SyliusUser (an alternative to SonataUserBundle)

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Marcos Bezerra de Menezes

symfony sylius sonata admin

26/09 2017

dev-wip-locale

dev-wip-locale https://github.com/libre-informatique/SonataSyliusUserBundle

Symfony bundle providing a bridge between SonataAdmin and SyliusUser (an alternative to SonataUserBundle)

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Marcos Bezerra de Menezes

symfony sylius sonata admin

15/09 2017

0.5.1

0.5.1.0 https://github.com/libre-informatique/SonataSyliusUserBundle

Symfony bundle providing a bridge between SonataAdmin and SyliusUser (an alternative to SonataUserBundle)

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Marcos Bezerra de Menezes

symfony sylius sonata admin

15/09 2017

dev-wip-test

dev-wip-test https://github.com/libre-informatique/SonataSyliusUserBundle

Symfony bundle providing a bridge between SonataAdmin and SyliusUser (an alternative to SonataUserBundle)

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Marcos Bezerra de Menezes

symfony sylius sonata admin

13/06 2017

0.4.3

0.4.3.0 https://github.com/libre-informatique/SonataSyliusUserBundle

Symfony bundle providing a bridge between SonataAdmin and SyliusUser (an alternative to SonataUserBundle)

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Marcos Bezerra de Menezes

symfony sylius sonata admin

05/05 2017

0.4.2

0.4.2.0 https://github.com/libre-informatique/SonataSyliusUserBundle

Symfony bundle providing a bridge between SonataAdmin and SyliusUser (an alternative to SonataUserBundle)

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Marcos Bezerra de Menezes

symfony sylius sonata admin