blurrywindows/yii2-auto-command

This package is abandoned and no longer maintained. No replacement package was suggested.

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

Installs: 5

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Type:yii2-extension

dev-master 2019-06-11 11:46 UTC

This package is not auto-updated.

Last update: 2021-11-24 18:11:28 UTC


README

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