opus-online / yii2-giimodel
Advanced Gii model generator for Yii2
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 1 707
Dependents: 1
Suggesters: 0
Security: 0
Stars: 6
Watchers: 3
Forks: 4
Open Issues: 0
Type:yii2-extension
Requires
This package is not auto-updated.
Last update: 2024-01-20 11:33:08 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