opus-online/yii2-giimodel

Advanced Gii model generator for Yii2

Installs: 1 501

Dependents: 1

Stars: 7

Watchers: 3

Forks: 5

Language: PHP

1.1.0 2014-08-11 11:33 UTC

README

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