ModelDoc Generator will extend Gii too allow you to update your existing models with phpDoc compatible documentation. The phpDoc comments greatly assist with phpStorm's code completion.
Features ¶
- Table Fields
- Adds properties for each field.
- Properties are annotated with field comments from the database.
- Relations
- Adds a property with a return type for each relation.
- CActiveRecord Inheritance
- Adds methods inherited from CActiveRecord including: find(), findByPk(), findByAttributes(), fndBySql(), findAll(), findAllByPk(), findAllByAttributes(), findAllBySql(), with(), together(), cache(), resetScope(), populateRecord() and populateRecords().
- Behaviors
- Adds a property with a return type for each behavior.
- Adds methods assigned for behaviors, unless it is defined by the model itself.
- Optionally uses @mixin for behaviors.
- Scopes
- Adds a method for each scope.
- Full Syntax
- All PHPDoc tags contain full syntax including: method params and return types.
- All returned models have namespace support.
Installation ¶
Please download using ONE of the following methods:
Composer Installation ¶
curl http://getcomposer.org/installer | php
php composer.phar require cornernote/gii-modeldoc-generator
Manual Installation ¶
Download the latest version and move the gii-modeldoc-generator
folder into your protected/extensions
folder.
Configuration ¶
Add the path to gii-modeldoc-generator to the generatorPaths
in your gii configuration:
return array(
'aliases' => array(
// set this so Yii knows where composers vendor folder is located
// only needed if you want to use the composer vendor alias below
'vendor' => '/path/to/vendor',
),
'modules' => array(
'gii' => array(
'class'=>'system.gii.GiiModule',
'generatorPaths' => array(
// use this if you installed with composer
'vendor.cornernote.gii-modeldoc-generator.gii',
// OR, use this if you downloaded into your extensions folder
//'ext.gii-modeldoc-generator.gii',
),
),
),
);
Usage ¶
Ensure you have --- BEGIN ModelDoc---
and --- END ModelDoc---
in each of your models, for example:
/**
* Your class description that will not be altered by ModelDoc
*
* --- BEGIN ModelDoc ---
*
* this section will be replaced by ModelDoc
*
* --- END ModelDoc ---
*/
class MyModel extends CActiveRecord { ... }
Visit index.php?r=gii
, then choose ModelDoc from the menu.
Notes ¶
This extension will not create any new model files. You should first create them or generate them with a model generator.
Resources ¶
Support ¶
- Found a bug, or need help using this project? Check the open issues or create an issue.
License ¶
BSD-3-Clause, Copyright © 2013-2014 Mr PHP
Feedback
Awesome extension! :) Makes it easy to keep your model parameters and relations up to date.
Questions? Leave an issue.
Please report any questions or issues here:
https://github.com/cornernote/gii-modeldoc-generator/issues/new
If you have any love/hate mail (that does not need an answer) feel free to post it to the comments here.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.