philiplb/crudlexsymfony4bundle

CRUDlex的Symfony 4集成。

0.1.0 2018-09-07 15:07 UTC

This package is not auto-updated.

Last update: 2024-09-15 12:57:13 UTC


README

此包提供了在Symfony 4项目中集成CRUDlex的功能。

安装

使用Symfony Flex的应用程序

打开命令行,进入您的项目目录并执行

$ composer require philiplb/crudlexsymfony4bundle

不使用Symfony Flex的应用程序

步骤 1: 下载Bundle

打开命令行,进入您的项目目录并执行以下命令以下载此bundle的最新稳定版本

$ composer require philiplb/crudlexsymfony4bundle

此命令要求您全局安装了Composer,具体请参阅Composer文档中的安装章节

请注意,不幸的是,一个依赖项需要composer.json接受不稳定版本

"minimum-stability": "dev",
"prefer-stable": true,

步骤 2: 启用Bundle

将bundle添加到您的config/bundles.php

<?php
// config/bundles.php

return [
    // ...
    philiplb\CRUDlexSymfony4Bundle\CRUDlexSymfony4Bundle::class => ['all' => true],
    //...
];

或者,根据您的设置,通过将bundle添加到项目的app/AppKernel.php文件中注册的bundle列表中来启用bundle

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new philiplb\CRUDlexSymfony4Bundle\CRUDlexSymfony4Bundle(),
        );

        // ...
    }

    // ...
}

步骤 3: 添加路由

CRUDlex提供了一些路由,因此它们必须添加到您的config/routes.yaml中。这使得它们在/crud下可用

crudlex:
    resource: '@CRUDlexSymfony4Bundle/Resources/config/routes.yaml'
    prefix: /crud

步骤 4: 配置服务以满足您的需求

CRUDlexSymfony4Bundle基本上是一块服务。一些配置,如crud.yml的位置,在这里发生。您可以通过config/services.yaml覆盖每个服务以适应您的需求。以下是完整的配置选项

services:
    crudlex.dataFactoryInterface:
        public: true
        class: "CRUDlex\\MySQLDataFactory"
        arguments:
          - "@doctrine.dbal.default_connection"
    crudlex.entityDefinitionFactoryInterface:
        public: true
        class: "CRUDlex\\EntityDefinitionFactory"
    crudlex.fileSystemAdapter:
        public: true
        class: "League\\Flysystem\\Adapter\\Local"
        arguments:
          - "%kernel.project_dir%/var"
    crudlex.fileSystem:
        public: true
        class: "League\\Flysystem\\Filesystem"
        arguments:
          - "@crudlex.fileSystemAdapter"
    crudlex.entityDefinitionValidatorInterface:
        public: true
        class: "CRUDlex\\EntityDefinitionValidator"
    crudlex.service:
        public: true
        class: "CRUDlex\\Service"
        arguments:
          - "%kernel.project_dir%/config/crud.yml"
          - "%kernel.cache_dir%"
          - "@Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface"
          - "@translator"
          - "@crudlex.dataFactoryInterface"
          - "@crudlex.entityDefinitionFactoryInterface"
          - "@crudlex.fileSystem"
          - "@crudlex.entityDefinitionValidatorInterface"
    CRUDlex\Controller:
        public: true
        class: "CRUDlex\\Controller"
        arguments:
          - "@crudlex.service"
          - "@crudlex.fileSystem"
          - "@twig"
          - "@session"
          - "@translator"
    kernel.listener.crudlex:
        class: philiplb\CRUDlexSymfony4Bundle\EventListener\RequestListener
        tags:
            - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }
        arguments:
          - "@crudlex.service"
          - "@session"
          - "@translator"
    crudlex.twigExtensions:
        class: "philiplb\\CRUDlexSymfony4Bundle\\Twig\\CRUDlexExtension"
        tags: ["twig.extension"]
        arguments:
          - "@request_stack"
          - "@session"