Skip to content
This repository was archived by the owner on Nov 19, 2021. It is now read-only.

Yii 2 command that generates models for a database and apidoc documentation based on code comments.

License

Notifications You must be signed in to change notification settings

bart-sysf/yii2-auto-command

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Yii 2 Auto Command

GitHub tag Packagist Packagist GitHub issues

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.

TABLE OF CONTENTS

FEATURES

  • Generates model classes based on the given database connection.
  • Generates model classes that extend a (custom) base class.
  • Generates apidoc documentation based on apidoc comment blocks in a custom folder.

REQUIREMENTS

INSTALLATION

composer require blurrywindows/yii2-auto-command

CONFIGURATION

Add the following lines to your console.php configuration:

'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'],
        ],
    ],

CONSOLE COMMANDS

./yii auto/all

Executes all the actions in the AutoController.

./yii auto/gii-models

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.

./yii auto/apidoc

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.

HOW TO CONTRIBUTE

You may contribute in any way you want, but please contact me beforehand to prevent merge-conflicts by creating an issue.

ISSUES

If you have any questions or experience any issues with this command, please submit an issue.

READ MORE

About

Yii 2 command that generates models for a database and apidoc documentation based on code comments.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages