micayael/admin-lte-maker-bundle

安装: 0

依赖者: 0

建议者: 0

安全: 0

星标: 0

观察者: 2

分支: 0

类型:symfony-bundle

dev-master 2020-01-20 21:12 UTC

README

  • 在 composer.json 中指定 PHP 最低版本: "php": "^7.3",
  • 添加 .php-version 文件并指定版本 7.3
  • 安装开发依赖
composer require --dev friendsofphp/php-cs-fixer sensiolabs/security-checker
  • 在 .php_cs.dist 文件中添加异常
->exclude(['bin', 'var', 'vendor', 'node_modules'])
  • 在 composer.json 中添加脚本
        "check-cs": [
            "php-cs-fixer fix --dry-run"
        ],
        "check-sec": [
            "security-checker -vv security:check"
        ],
        "check": [
            "@check-cs",
            "@check-sec"
        ],
        "fix-cs": [
            "php-cs-fixer fix"
        ]
  • 允许贡献
composer config extra.symfony.allow-contrib true
  • 安装依赖
composer require symfony/apache-pack
  • 提交项目

  • 安装 kevinpapst/adminlte-bundle。查看其页面

composer require "kevinpapst/adminlte-bundle:^3.0"
  • 在 composer.json 中将 twig 版本锁定为 2
        "twig/twig": "2.*"
  • 安装 composer require micayael/admin-lte-maker-bundle:*@dev
composer require micayael/admin-lte-maker-bundle:*@dev
  • 创建 admin.html.twig
cp vendor/micayael/admin-lte-maker-bundle/doc/examples/admin.html.twig templates/
  • 安装并配置 KnpPaginatorBundle,覆盖 templates/bundles/KnpPaginatorBundle 文件
composer require knplabs/knp-paginator-bundle:^4.1

cp vendor/micayael/admin-lte-maker-bundle/doc/examples/knp_paginator.yaml config/packages/
mkdir -p templates/bundles/KnpPaginatorBundle/Pagination/
cp vendor/micayael/admin-lte-maker-bundle/doc/examples/twitter_bootstrap_v3_sortable_link.html.twig templates/bundles/KnpPaginatorBundle/Pagination/
  • 在 .env 中配置数据库

  • 准备认证

    • 安装 doctrine 扩展
    composer require stof/doctrine-extensions-bundle
    
    • 配置 doctrine 扩展

      stof_doctrine_extensions:
        default_locale: es
        orm:
            default:
                timestampable:  true
                blameable:  true
      
      
      • 配置翻译文件 translation.yaml
      framework:
          default_locale: es
          translator:
              default_path: '%kernel.project_dir%/translations'
              fallbacks:
                  - es
      
      
      • 为 fos user bundle 创建 User 对象
      cp vendor/micayael/admin-lte-maker-bundle/doc/examples/Usuario.php src/Entity/
      cp vendor/micayael/admin-lte-maker-bundle/doc/examples/UsuarioRepository.php src/Repository/
      
      • 配置 .env
      ###> friendsofsymfony/user-bundle ###
      FROM_EMAIL_ADDRESS=micayael@hotmail.com
      FROM_EMAIL_SENDER_NAME=webmaster
      ###< friendsofsymfony/user-bundle ###
      
      • 配置 security.yaml
      mkdir -p src/Security
      cp vendor/micayael/admin-lte-maker-bundle/doc/examples/Security/CustomUserProvider.php src/Security/
      cp vendor/micayael/admin-lte-maker-bundle/doc/examples/routes/fos_user.yaml config/routes/
      cp vendor/micayael/admin-lte-maker-bundle/doc/examples/security.yaml config/packages/security.yaml
      cp vendor/micayael/admin-lte-maker-bundle/doc/examples/fos_user.yaml config/packages/
      
      • 为用户创建数据库和表
      bin/console cache:clear
      bin/console doctrine:database:create
      bin/console doctrine:schema:create
      bin/console fos:user:create --super-admin
      
  • 创建实体

    • 注意主键的自动编号
    @ORM\GeneratedValue(strategy="IDENTITY")
    
    • 在每个实体中始终创建一个 $revision 属性
        /**
         * @ORM\Column(type="integer", options={"default":1})
         *
         * @ORM\Version()
         */
        private $revision;
    
  • 生成 CRUD

bin/console make:app:crud
  • 在 routes.yaml 中创建 home 路径
home:
    path: /
    controller: App\Controller\HomeController
    methods: GET
  • 创建 home 控制器
cp vendor/micayael/admin-lte-maker-bundle/doc/examples/Controller/HomeController.php src/Controller/
mkdir templates/admin
cp vendor/micayael/admin-lte-maker-bundle/doc/examples/templates/home.html.twig templates/admin/
  • 创建 index 控制器
cp vendor/micayael/admin-lte-maker-bundle/doc/examples/Controller/IndexController.php src/Controller/
mkdir templates/public
cp vendor/micayael/admin-lte-maker-bundle/doc/examples/templates/index.html.twig templates/public/
  • 在主 admin.js 中引入 assets
require('../../vendor/micayael/admin-lte-maker-bundle/src/Resources/assets/crud.scss');
  • 安装 URL 加密
composer require nzo/url-encryptor-bundle:^4.2

要使用此包

micayael_admin_lte_maker.yaml

micayael_admin_lte_maker: url_context: /

缺少

  • 添加事件 fire
  • 添加命令选项
    • 指明要创建的内容
      • 仅表单
      • 仅模板
      • 仅路由
      • 仅控制器
    • 有或无权限