2017 © Pedro PelĂĄez
 

symfony-bundle deveosys_admin

Admin generator for Symfony applications

image

deveosys/deveosys_admin

Admin generator for Symfony applications

  • Tuesday, July 10, 2018
  • by Deveosys
  • Repository
  • 1 Watchers
  • 0 Stars
  • 19 Installations
  • HTML
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 46 % Grown

The README.md

DeveosysAdmin

DeveosysAdmin is based on top of EasyAdmin and FOSUserBundle., (*1)

It brings boilerplate code for users management and bootstrap 4 integration., (*2)

Development in progress..., (*3)

Installation

Packages

Install symfony/templating for FOSUserBundle dependency :, (*4)

$ composer require symfony/templating

Add this to your app/config/config.yml :, (*5)

framework:
    [...]
    templating:
        engines: ['twig']

Add DeveosysAdmin Package :, (*6)

$ composer require deveosys/deveosys_admin "dev-master"

Activate the bundles in app/AppKernel.php, (*7)

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            [...]
            // EasyAdminBundle
            new EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle(),
            // FOSUserBundle
            new FOS\UserBundle\FOSUserBundle(),
            // DeveosysAdminBundle
            new Deveosys\AdminBundle\DeveosysAdminBundle(),
        ];
    [...]
    }
[...]
}

Routing

Import routing in your app/config/routing.yml :, (*8)

It already imports routes from EasyAdminBundle and FOSUserBundle, (*9)

deveosys_admin:
    resource: "@DeveosysAdminBundle/Resources/config/routing.yml"
    prefix:   /

Configuration

Create a deveosysAdmin.yml file in app/config :, (*10)

or paste the following directly in app/config/config.yml, (*11)

easy_admin:
    site_name: 'Deveosys <small>Admin</small>'
    formats:
        date:     'd/m/Y'
    design:
        templates:
            layout: 'DeveosysAdminBundle:easy_admin:layout.html.twig'
            menu: 'DeveosysAdminBundle:easy_admin:menu.html.twig'
            edit: 'DeveosysAdminBundle:easy_admin:edit.html.twig'
            new: 'DeveosysAdminBundle:easy_admin:new.html.twig'
            list: 'DeveosysAdminBundle:easy_admin:list.html.twig'
            field_toggle: 'DeveosysAdminBundle:easy_admin:field_toggle.html.twig'
        assets:
            css:
                - 'bundles/deveosysadmin/dist/global.css'
            js:
                - 'bundles/deveosysadmin/dist/app.js'
        menu:
            - { label: 'Dashboard', route: 'admin_dashboard', default: true, icon: 'tachometer' }
            - { entity: 'User', icon: 'users' }
    entities:
        User:
            class: Deveosys\AdminBundle\Entity\User
            label: users
            list:
                title: users
                help: user.management
                sort: 'id'
                translation_domain: 'FOSUserBundle'
                fields:
                    - username
                    - { property: 'email', type: 'email' }
                    - enabled
                    - lastLogin
            form:
                fields:
                    - username
                    - email
                    # if administrators are allowed to edit users' passwords and roles, add this:
                    - { property: 'plainPassword', type: 'text', type_options: { required: false } }
                    - { property: 'roles', type: 'choice', type_options: { multiple: true, choices: { 'User': 'ROLE_USER', 'Admin': 'ROLE_ADMIN' } } }
            new:
                form_options: { validation_groups: ['Profile', 'Registration'] }
            edit:
                form_options: { validation_groups: ['Profile'] }

fos_user:
    db_driver: orm # other valid values are 'mongodb' and 'couchdb'
    firewall_name: main
    user_class: Deveosys\AdminBundle\Entity\User
    from_email:
        address: "%mailer_user%"
        sender_name: "%mailer_user%"

deveosys_admin:
    login: ~

And import it in your app/config/config.yml :, (*12)

imports:
    [...]
    - { resource: deveosysAdmin.yml }

Edit you app/config/security.yml file as you want but there is an example :, (*13)

security:
    encoders:
        FOS\UserBundle\Model\UserInterface: bcrypt

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: ROLE_ADMIN

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username

    firewalls:
        main:
            logout_on_user_change: true
            pattern: ^/
            form_login:
                provider: fos_userbundle
                csrf_token_generator: security.csrf.token_manager

            logout:       true
            anonymous:    true
            # pattern:  ^/(_(profiler|wdt)|css|images|js)/
            # security: false

    access_control:
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/, role: ROLE_ADMIN }

Set the mailer_user parameter in app/config/parameter.yml, (*14)

mailer_user: your@mail.com

Activate translation in app/config/config.yml :, (*15)

framework:
    ...
    translator: { fallbacks: [ '%locale%' ] }

 Assets

Install assets :, (*16)

php bin/console assets:install

Update database

We recommend that you use DoctrineMigrationsBundle :, (*17)

php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate

Otherwise :, (*18)

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

FOSUserBundle Login and Registration templates overriding

So far, standard FOSUserBundle templates are used for these pages. DeveosysAdminBundle can provide improved templates integrating bootstrap 4 that you can easily modify at your convenience in app/Resources/FOSUserBundle., (*19)

To generate it :, (*20)

php bin/console deveosys:install:fosuser_templates

License

This software is published under the MIT License, (*21)

The Versions