pafnow/yii2-giiant 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pafnow/yii2-giiant

Composer 安装命令:

composer require pafnow/yii2-giiant

包简介

Gii CRUD generator for Yii 2 Framework

README 文档

README

  • Traits for CRUD controllers action
  • RelationProvider orderBy displayed name in dropdown fields
  • Custom dbType yii2image ad yii2file for image and file automatic model generation
  • CRUD FileProvider to handle image upload

yii2-giiant

Extended models and CRUDs for Gii, the code generator of Yii2 Framework

PROJECT IS IN DEVELOPMENT STAGE!

What is it?

Giiant provides templates for model and CRUD generation with relation support and a sophisticated UI. A main project goal is porting many features and learnings from gtc, giix, awecrud and others into one solution.

Installation

The preferred way to install this extension is through composer.

composer.phar require schmunk42/yii2-giiant:"*"

The generators are registered automatically in the application bootstrap process, if the Gii module is enabled

Usage

Visit your application's Gii (eg. index.php?r=gii and choose one of the generators from the main menu screen.

For basic usage instructions see the Yii2 Guide section for Gii.

Command Line Batches

You can run batches of base-model and CRUD generation with the build in batch command:

./yii giiant-batch --tables=profile,social_account,user,token

It will process the given tables, for more details see ./yii help giiant-batch.

Features

Model generator

  • generates separate model classes to customize and base models classes to regenerate
  • table prefixes can be stipped off model class names (not bound to db connection setting)

CRUD generator

  • model, view and controller locations can be customized to use subfolders
  • horizontal and vertical form layout
  • action button class customization
  • input, attribute, column and relation customization with provider queue
  • callback provider to inject any kind of code for inputs, attributes and columns via dependency injection

Providers

  • CallbackProvider universal provider to modify any input, attribute or column with highly flexible callback functions
  • RelationProvider renders code for relations (eg. links, dropdowns)
  • EditorProvider renders RTE, like Ckeditor as input widget
  • DateTimeProvider renders date inputs

Customization with providers

In many cases you want to exchange i.e. some inputs with a customized version for your project. Examples for this use-case are editors, file-uploads or choosers, complex input widget with a modal screen, getting data via AJAX and so on.

With Giiant Providers you can create a queue of instances which may provide custom code depending on more complex rules. Take a look at some existing giiant providers.

Configure providers, add this to your provider list in the form:

\schmunk42\giiant\crud\providers\EditorProvider,
\schmunk42\giiant\crud\providers\SelectProvider,

And configure the settings of the provider, add setting via dependecy injection this to your application config, eg. in console/config/bootstrap.php:

\Yii::$container->set(
    'schmunk42\giiant\crud\providers\EditorProvider',
    [
        'columnNames' => ['description']
    ]
);

This will render a Ckeditor widget for every column named description.

<?= $form->field($model, 'description')->widget(
\dosamigos\ckeditor\CKEditor::className(),
[
    'options' => ['rows' => 6],
    'preset' => 'basic'
]) ?>

Universal CallbackProvider

Configuration via DI container:

\Yii::$container->set(
    'schmunk42\giiant\crud\providers\CallbackProvider',
    [

        'activeFields'  => [

           /**
            * Generate a checkbox for specific column (model attribute)
            */
           'common\models\Foo.isAvailable' => function ($attribute, $generator) {
               $data = \yii\helpers\VarDumper::export([0 => 'Nein', 1 => 'Ja']);
               return <<<INPUT
\$form->field(\$model, '{$attribute}')->checkbox({$data});
INPUT;
           },
        ],


        'columnFormats' => [

           /**
            * generate custom HTML in column
            */
           'common\models\Foo.html' => function ($attribute, $generator) {

               return <<<FORMAT
[
    'format' => 'html',
    'label'=>'FOOFOO',
    'attribute' => 'item_id',
    'value'=> function(\$model){
        return \yii\helpers\Html::a(\$model->bar,['/crud/item/view', 'id' => \$model->link_id]);
    }
]
FORMAT;
           },


           /**
            * hide all text fields in grid
            */
           '.+' => function ($column, $model) {
                    if ($column->dbType == 'text') {
                        return false;
                    }
           },

           /**
            * hide system fields in grid
            */
           'created_at$|updated_at$' => function () {
                   return false;
           },

        ]
    ]
);

Extras

A detailed description how to use MySQL workbench for model updates and migration see here.

Special thanks to motin, thyseus, uldisn and rcoelho for their work, inspirations and feedback.

Links

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 117
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2014-11-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固