PHP code example of myzero1 / yii2-apibyconf

1. Go to this page and download the library: Download myzero1/yii2-apibyconf library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

myzero1 / yii2-apibyconf example snippets


...
if (!YII_ENV_TEST) {
    // configuration adjustments for 'dev' environment
    ...
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
    ];
    $config['modules']['gii']['generators'] = [
        'rest' => [
            'class' => 'myzero1\apibyconf\components\gii\generators\rest\Generator'
        ],
    ];
    ...
}
...

return [
    ......
    'bootstrap' => [
        ......
        'example',
        ......
    ],
    ......
    'modules' => [
        ......
        'example' => '\myzero1\apibyconf\example\ApiByConfModule',// should add table to db by 'example/models/user.sql'
        'apibyconf' => 'myzero1\apibyconf\Module',
        ......
    ],
    ......
    'components' => [
        ......
        'user' => [
            'identityClass' => 'myzero1\apibyconf\components\rest\ApiAuthenticator',
            'enableSession' => false,
            'authTimeout' => 3600 * 24, // defafult 24h
        ],
        ......
    ]
    ......
];

return [
    ......
    'bootstrap' => [
        ......
        'v1',
        ......
    ],
    ......
    'modules' => [
        ......
        'v1' => [
            'class' => 'backend\modules\v1\ApiByConfModule',
            'docToken' => 'docTokenAsMyzero1',
            'apiTokenExpire' => 24 * 3600 * 365,
            'fixedUser' => [
                'id' => '1',
                'username' => 'myzero1',
                'api_token' => 'myzero1Token',
            ],
            'runningAsDocActions' => [
                // '*' => '*', // all ations, as default
                // 'controllerA' => [
                //     '*', // all actons in controllerA
                // ],
                // 'controllerB' => [
                //     'actionB',
                // ],
                'user' => [
                    'create',
                    'index',
                ],
            ],
        ],
        ......
    ],
    ......
];

php composer.phar