gales/maker-bundle

基于 Petkopara Crud Generator 的 ABM 生成器,重用 Symfony Maker Bundle 的代码

安装: 300

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 2

开放性问题: 0

类型:symfony-bundle

v0.5.8 2023-10-24 15:37 UTC

README

Symfony4 / 5 CRUD 生成器包,具有分页、过滤、Twitter Bootstrap v4.6 标记和许多其他功能。使用简单,完全可定制。

设计用于恢复 PetkoparaCrudGeneratorBundle 的功能,但重用 Symfony 的 Maker Bundle 的逻辑。

安装步骤

使用 composer 添加 Bundle

composer require gales/maker-bundle:^0.1

本地开发和测试步骤

将 bundle 的仓库克隆到要添加 bundle 的项目外,例如在项目根目录下

mkdir ../bundles
cd ../bundles
git clone https://github.com/GALes/maker-bundle.git

在项目的 composer.json 中添加以下仓库

"repositories":[
    {
        "type": "path",
        "url": "../bundles/maker-bundle"
    }
],
"minimum-stability": "dev",
"prefer-stable": true

使用 composer 添加以下 Bundle

composer require gales/maker-bundle:*@dev

然后执行以下操作

composer dump-autoload

在 Twig 配置中添加使用 Bootstrap 4 表单主题

# config/packages/twig.yaml
twig:
    form_themes: ['bootstrap_4_layout.html.twig']

使用方法

执行以下命令

php bin/console gales:make:crud

注意

  • 列表:为了定义用于关联实体列排序的可用字段,可以在该实体中使用以下注解(@GalesMaker(orderBy=nombre_propiedad))。例如:请求列表具有显示状态的列,但希望按此排序
// src/Entity/Solicitud.php
namespace App\Entity;
...
class SolicitudBanco
{
    ...
    /**
     * @ORM\ManyToOne(targetEntity=SolicitudEstado::class)
     * @ORM\JoinColumn(nullable=false)
     */
    private $estado;
    ...
// src/Entity/SolicitudEstado.php
namespace App\Entity;
...
/**
 ...
 * @GalesMaker(orderBy="descripcion")
 */
class SolicitudEstado
{
    ...
    private $descripcion;
    ...

由 bundle 生成的文件

然后选择要生成 ABM 的实体。生成的文件

created: src/Service/<entity_name>CrudService.php (Logica auxiliar para el funcionamiento del ABM)
created: src/Controller/<entity_name>Controller.php (Controlador con la logica del ABM)
created: src/Form/<entity_name>Type.php (Formulario para el alta/edicion de la entidad)
created: src/Form/<entity_name>(Full)FilterType.php (Filtro del listado)
created: templates/<entity_name>/edit.html.twig (Vista de edicion de la entidad)
created: templates/<entity_name>/index.html.twig  (Vista para el listado de entidades)
created: templates/<entity_name>/new.html.twig  (Vista de creacion de nueva entidad)
created: templates/<entity_name>/show.html.twig (Vista de visualizacion de los datos de la entidad)