'urlManager' => [ 'class' => 'yiiwebUrlManager', 'enablePrettyUrl' => true, 'enableStrictParsing' => true, 'showScriptName' => false, 'rules' => [ '' => 'cms/index', ['class' => 'yii estUrlRule', 'controller' => 'customer/api', 'pluralize' => false, ], # 定义方法: public function actionSearch($name); <name> 就是search方法传入的参数 'POST customer/api/search/<name>' => 'customer/api/search', //'POST customer' => 'customer/index/create', ], ],
这个配置可以解决加上 'pluralize' => false
<?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' => 'app-api', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'apicontrollers', 'modules' => [ 'v1' => [ 'class' => 'apimodulesv1Modules', ], ], 'components' => [ 'request' => [ 'csrfParam' => '_csrf-api', ], 'user' => [ 'identityClass' => 'commonmodelsUser', 'enableAutoLogin' => true, 'identityCookie' => ['name' => '_identity-api', 'httpOnly' => true], ], 'session' => [ // this is the name of the session cookie used for login on the frontend 'name' => 'advanced-api', ], 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => 'yiilogFileTarget', 'levels' => ['error', 'warning'], ], ], ], 'errorHandler' => [ 'errorAction' => 'site/error', ], 'urlManager' => [ 'enablePrettyUrl' => true, 'enableStrictParsing' => true, 'showScriptName' => false, 'rules' => [ ['class' => 'yii estUrlRule', 'controller' => 'v1/user', 'pluralize' => false,], ], ], ], 'params' => $params, ];