2017 © Pedro Peláez
 

yii2-extension yii2-giix

Extended Gii for Yii 2 Framework

image

veyselsahin/yii2-giix

Extended Gii for Yii 2 Framework

  • Friday, February 12, 2016
  • by veyselsahin
  • Repository
  • 4 Watchers
  • 8 Stars
  • 380 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 3 Versions
  • 4 % Grown

The README.md

yii2-giix

Extended models and CRUDs for Gii, the code generator of Yii2 Framework, (*1)

PROJECT IS IN DEVELOPMENT STAGE!, (*2)

What is it?

Yii2-Giix 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 yii2-giiant, gtc, giix, awecrud and others into one solution., (*3)

Installation

The preferred way to install this extension is through composer., (*4)

composer.phar require veyselsahin/yii2-giix:"*"

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

Usage

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

For basic usage instructions see the Yii2 Guide section for Gii., (*7)

Command Line Batches

You can run batches of base-model and CRUD generation with the build in batch command:, (*8)

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

It will process the given tables, for more details see ./yii help giix-batch., (*9)

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

Use custom generators, model and crud templates


$config['modules']['gii'] = [ 'class' => 'yii\gii\Module', 'allowedIPs' => ['127.0.0.1'], 'generators' => [ // generator name 'rb-model' => [ //generator class 'class' => 'veyselsahin\giix\model\Generator', //setting for out templates 'templates' => [ // template name => path to template 'rbModel' => '@app/giiTemplates/model/default', ] ] ], ];

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., (*10)

With Yii2-Giix Providers you can create a queue of instances which may provide custom code depending on more complex rules. Take a look at some existing giix providers., (*11)

Configure providers, add this to your provider list in the form:, (*12)

\veyselsahin\giix\crud\providers\EditorProvider,
\veyselsahin\giix\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:, (*13)

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

This will render a Ckeditor widget for every column named description., (*14)

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

Universal CallbackProvider

Configuration via DI container:, (*15)

\Yii::$container->set(
    'veyselsahin\giix\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., (*16)

php yii.php giix-batch --modelDb=cafees --modelBaseClass=common\models\VysModel --modelNamespace=backend\models --tables=gruplar,sinav,sinav_sonuc, (*17)

php yii.php giix-batch --modelDb=cafees --modelBaseClass=common\models\VysModel --modelNamespace=backend\models, (*18)

The Versions

12/02 2016

dev-master

9999999-dev https://github.com/veyselsahin/yii2-giix

Extended Gii for Yii 2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

yii2 crud gii

12/02 2016

1.2

1.2.0.0 https://github.com/veyselsahin/yii2-giix

Extended Gii for Yii 2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

yii2 crud gii

12/08 2015

1.1

1.1.0.0 https://github.com/veyselsahin/yii2-giix

Extended Gii for Yii 2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

yii2 crud gii