PHP code example of myzero1 / yii2-restbyconf
1. Go to this page and download the library: Download myzero1/yii2-restbyconf 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-restbyconf 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\restbyconf\components\gii\generators\rest\Generator'
],
];
...
}
...
return [
......
'bootstrap' => [
......
'example',
'v1',
......
],
......
'modules' => [
......
'restbyconf' => 'myzero1\restbyconf\Module',
'example' => [
'class' => 'myzero1\restbyconf\example\RestByConfModule',// should add table to db by 'yii2-restbyconf/src/user.sql'
'apiTokenExpire' => 24 * 3600 * 365,
'fixedUser' => [
'id' => '1',
'username' => 'myzero1',
'api_token' => 'myzero1Token',
],
'smsAndCacheComponents' => [
'captchaCache' => [
'class' => '\yii\caching\FileCache',
'cachePath' => '@runtime/captchaCache',
],
'captchaSms' => [
'class' => 'myzero1\smser\QcloudsmsSmser',// 腾讯云
'appid' => '1400280810', // 请替换成您的appid
'appkey' => '23e167badfc804d97d454e32e258b780', // 请替换成您的apikey
'smsSign' => '玩索得',
'expire' => '5',//分钟
'templateId' => 459670, // 请替换成您的templateId
],
],
'runningAsDocActions' => [
'*' => '*', // all ations, as default
// 'controllerA' => [
// '*', // all actons in controllerA
// ],
// 'controllerB' => [
// 'actionB',
// ],
],
],
......
],
......
'components' => [
......
// 'assetManager' => [
// 'class' => 'yii\web\AssetManager',
// 'forceCopy' => true,// true/false
// ],
'user' => [
'identityClass' => 'myzero1\restbyconf\components\rest\ApiAuthenticator',
'enableSession' => false,
'authTimeout' => 3600 * 24, // defafult 24h
],
......
]
......
];
return [
......
'bootstrap' => [
......
'v2',
......
],
......
'modules' => [
......
'v2' => [
'class' => 'api\modules\v2\RestByConfModule',
'apiTokenExpire' => 24 * 3600 * 365,
'fixedUser' => [
'id' => '1',
'username' => 'myzero1',
'api_token' => 'myzero1Token',
],
'smsAndCacheComponents' => [
'captchaCache' => [
'class' => '\yii\caching\FileCache',
'cachePath' => '@runtime/captchaCache',
],
'captchaSms' => [
'class' => 'myzero1\smser\QcloudsmsSmser',// 腾讯云
'appid' => '1400280810', // 请替换成您的appid
'appkey' => '23e167badfc804d97d454e32e258b780', // 请替换成您的apikey
'smsSign' => '玩索得',
'expire' => '5',//分钟
'templateId' => 459670, // 请替换成您的templateId
],
],
'runningAsDocActions' => [
'*' => '*', // all ations, as default
// 'controllerA' => [
// '*', // all actons in controllerA
// ],
// 'controllerB' => [
// 'actionB',
// ],
],
],
......
],
......
];
return [
......
'bootstrap' => [
......
'classMap' => function(){
Yii::$classMap['myzero1\restbyconf\components\rest\Helper'] = '@app/modules/v1/components/Helper.php';
Yii::$classMap['myzero1\restbyconf\components\rest\ApiHelper'] = 'path/to/ApiHelper.php';
},
......
],
......
];
php composer.phar