You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

78 lines
2.7 KiB

<?php
$params = array_merge(
require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php'
);
return [
'id' => 'api',
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'api\controllers',
'bootstrap' => ['log'],
'modules' => [],
'components' => [
'cartLogic' => ['class' => 'api\logic\CartLogic'],
'orderLogic' => ['class' => 'api\logic\OrderLogic'],
'userLogic' => ['class' => 'api\logic\UserLogic'],
'request' => [
'parsers' => [
'application/json' => 'yii\web\JsonParser',
],
'csrfParam' => '_csrf-api',
],
'session' => [
// this is the name of the session cookie used for login on the app
'name' => 'api',
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'identityCookie' => ['name' => '_identity-api', 'httpOnly' => true],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'urlManager' => [
'enablePrettyUrl' => true,
'enableStrictParsing' => true,
'showScriptName' => false,
'rules' => [
['class' => 'yii\rest\UrlRule', 'controller' => 'goods', 'pluralize' => false],
['class' => 'yii\rest\UrlRule', 'controller' => 'cart'],
['class' => 'yii\rest\UrlRule', 'controller' => 'order'],
['class' => 'yii\rest\UrlRule',
'controller' => 'user',
'pluralize' => false,
'extraPatterns' => [
'GET token' => 'token'
]
],
[
'class' => 'yii\rest\UrlRule',
'controller' => 'admin',
'extraPatterns' => [
'GET menu' => 'menu',
'GET create' => 'create'
]
],
[
'class' => 'yii\rest\UrlRule',
'controller' => 'site',
'extraPatterns' => [
'GET index' => 'index',
]
],
],
],
],
'params' => $params,
];