deveosys/deveosys_admin

Symfony应用的Admin生成器

安装: 20

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

语言:HTML

类型:symfony-bundle

dev-master 2018-07-10 09:08 UTC

This package is not auto-updated.

Last update: 2024-09-25 12:14:52 UTC


README

DeveosysAdmin基于EasyAdmin和FOSUserBundle。

它为用户管理和Bootstrap 4集成提供样板代码。

开发中...

安装

为FOSUserBundle依赖安装symfony/templating

$ composer require symfony/templating

将以下内容添加到您的app/config/config.yml中

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

添加DeveosysAdmin包

$ composer require deveosys/deveosys_admin "dev-master"

在app/AppKernel.php中激活束

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

路由

导入app/config/routing.yml中的路由

它已经导入了EasyAdminBundle和FOSUserBundle的路由

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

配置

在app/config中创建deveosysAdmin.yml文件

或直接在app/config/config.yml中粘贴以下内容

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: ~

并在app/config/config.yml中导入它

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

根据需要编辑您app/config/security.yml文件,但有一个示例

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 }

在app/config/parameter.yml中设置mailer_user参数

mailer_user: your@mail.com

在app/config/config.yml中激活翻译

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

### 资源

安装资源

php bin/console assets:install

更新数据库

我们建议您使用DoctrineMigrationsBundle

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

否则

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

覆盖FOSUserBundle的登录和注册模板

到目前为止,标准FOSUserBundle模板已用于这些页面。DeveosysAdminBundle可以提供集成Bootstrap 4的改进模板,您可以在app/Resources/FOSUserBundle中轻松修改

要生成它

php bin/console deveosys:install:fosuser_templates

许可证

此软件根据MIT许可证发布