dev-master
9999999-devYii 2 command that generates models for a database and apidoc documentation based on code comments.
MIT
The Requires
- php >=5.6.0
- yiisoft/yii2 ~2.0.5
Yii 2 command that generates models for a database and apidoc documentation based on code comments.
This is a Yii 2 extension (command) that may be used to automatically generate model classes and apidoc documentation. The actions in this command should normally not run on a production server. The actions mentioned here generate files and data that may be used in development or testing. When executing these actions in a production environment, the controller will generate a warning prompt that you may override., (*2)
npm install -g apidoc
)composer require blurrywindows/yii2-auto-command
, (*3)
Add the following lines to your console.php
configuration:, (*4)
'controllerMap' => [ 'auto' => [ 'class' => 'blurrywindows\AutoCommand\AutoCommand', 'baseClass' => 'app\models\BaseActiveRecord', // or 'yii\db\ActiveRecord' if you want to use the Yii 2 ActiveRecord as base 'modelsFolder' => 'models', //Relative to app directory 'modelsNamespace' => 'app\models', 'apidocInputFolder' => 'controllers', //Relative to app directory 'apidocOutputFolder' => 'web/apidoc', //Relative to app directory 'skipTables' => ['migration'], ], ],
Executes all the actions in the AutoController., (*5)
Generates ActiveRecords for all the tables in your database in your chosen output folder.
It automatically overwrites the ActiveRecords if they exist.
The ActiveRecords are named Base[Tablename]
and extend your chosen baseClass.
It also creates a class [Tablename]
which extends Base[Tablename]
for custom code, extra validation rules, etc.
The [Tablename]
class will not be overridden when executing the action again., (*6)
Generates API documentation based on apidoc from the comments in your chosen input folder.
It outputs the documentation in your chosen output folder.
You may include this folder in Git if you want to export the documentation to a production server.
Please note, apidoc is a dev-dependency in Node.js. It will only be installed when using the npm install
command., (*7)
You may contribute in any way you want, but please contact me beforehand to prevent merge-conflicts by creating an issue., (*8)
If you have any questions or experience any issues with this command, please submit an issue., (*9)
Yii 2 command that generates models for a database and apidoc documentation based on code comments.
MIT