hoaaah / yii2-rest-api-template

REST API Template with Yii2
Other
33 stars 13 forks source link

How do config GII for create models #3

Closed matheuscamarques closed 3 years ago

matheuscamarques commented 3 years ago

How do config GII for create models?

hoaaah commented 3 years ago

Modified your config.php and add gii to bootstrap and modules.

<?php

return [
    'id' => 'micro-app',
    // the basePath of the application will be the `micro-app` directory
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['gii'],
    'modules' => [
        'v1' => [
            'class' => 'app\modules\v1\v1',
        ],
        'gii' => [
            'class' => 'yii\gii\Module',
        ],
    ],
    // this is where the application will find all controllers
    'controllerNamespace' => 'app\controllers',
    // set an alias to enable autoloading of classes from the 'micro' namespace
    'aliases' => [
        '@app' => __DIR__.'/../',
    ],
    'components' => [
        'urlManager' => [
            'class' => 'yii\web\UrlManager',
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                '<alias:\w+>' => 'site/<alias>',            
            ],
        ],
        'user' => [
            'identityClass' => 'app\models\UserIdentity',
            'enableAutoLogin' => false,
            'enableSession' => false,
            'loginUrl' => null,
        ],
        'request' => [
            'parsers' => [
                'application/json' => 'yii\web\JsonParser',
            ],
            'enableCsrfCookie' => false,
        ],
        'db' => $db,
    ],
    'params' => $params,
];

I haven't try it, but it should work. And don't forget to include "yiisoft/yii2-gii" to your composer.json.