opus-online/yii2-giimodel Advanced Gii model generator for Yii2

activerecordgiimodel

Advanced Gii model generator for Yii2

Generates 2 models classes instead of just one. This is useful if you are frequently re-generating your models from a schema and want to separate model definitions from custom functionality.

For example: table post

  • \common\models\base\Post - contains table meta (relations, property definitions, tableName, rules, attributeLabels)
  • \common\models\Post - is left almost empty for custom functionality

Installation

The easiest way to obtain the code is using Composer: just modify your composer.json to add a custom repository (linking to this project) and require the libary.

{
    "require": {
        "opus-online/yii2-giimodel": "1.1.*"
    }
}

Configuring

To add the Gii generator to your project, just add the class \opus\giimodel\Generator as a new generator to your gii module configuration:

'modules' => [
    'gii' => [
        'class' => 'yii\gii\Module',
        'allowedIPs' => ['*'],
        'generators' => [
            'giimodel' => [
                'class' => '\opus\giimodel\Generator',
                'prefixMap' => [
                    'tbl_user_' => 'user',
                    'tbl_' => '',
                    'ext_' => 'sub/dir',
                ]
            ]
        ]
    ]
]

Todos

  • Support for Search models
  • Remembering relation/base class names
  • Document namespace override parameters

Changelog

1.1.0

  • Now possible to group models using prefixes and subfolders
  • Intra-context relation getters shortened

1.0.0

  • Added support for overriding relation class name
  • Fixed issue with preceding slash of relation class namespace
  • Fixed issue where unselected base models still got generated
  • Added generating attribute PHPDoc from SQL field comments
  • Added support for yii2 1.0-beta

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



1.1.0 is the latest of 2 releases



Unknown license
Stats
6 github stars & 4 github forks
0 downloads in the last day
0 downloads in the last 30 days
1707 total downloads