错误请求,缺少必需的参数 Yii2

Bad Request, Missing required parameters Yii2

我的 GET 请求有问题。
如果我在我的应用中发送 /api/v1/users/user-settings?key=model-manual-user-settings 之类的 GET 请求, 我得到这样的回复:

{"name":"Bad Request","message":"Missing required parameters: key", "code":0, "status":400, "type":"yii\web\BadRequestHttpException"}

运行 方法在我的操作中

 /**
  * Получение пользовательских данных по ключу
  *
  * @param string $key Ключ пользовательских параметров
  * @return array
  */
  public function run($key)
  {
      $component = new UserSettingsComponent($key);
      return $component->getSettingsWithParams();
  }

一段 yii2 日志文件:

2018-05-25 18:58:52 [127.0.0.1][1][tsdsfjgmllh43vfb264qimc3fv][error][yii\web\HttpException:400] yii\web\BadRequestHttpException: Missing required parameters: key in /var/www/arm/vendor/yiisoft/yii2/web/Controller.php:149
Stack trace:
#0 /var/www/arm/vendor/yiisoft/yii2/base/Action.php(88): yii\web\Controller->bindActionParams(Object(api\actions\users\user_settings\IndexAction), Array)
#1 /var/www/arm/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\Action->runWithParams(Array)
#2 /var/www/arm/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction('index', Array)
#3 /var/www/arm/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction('v1/users/user-s...', Array)
#4 /var/www/arm/vendor/yiisoft/yii2/base/Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#5 /var/www/arm/api/web/index.php(15): yii\base\Application->run()
#6 {main}
2018-05-25 18:58:52 [127.0.0.1][1][tsdsfjgmllh43vfb264qimc3fv][info][application] $_GET = [
    'args' => ''
]

...

$_SERVER = [
    'USER' => 'www-data'
    'HOME' => '/var/www'
    'HTTP_X_COMPRESS' => 'null'
    'HTTP_COOKIE' => 'PHPSESSID=tsdsfjgmllh43vfb264qimc3fv; _csrf=f70915c9bfa9e77535bd94fa3287cb4347f248c120e26332eca5a1cebc7dba4ca%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%22mNhgJJk1mrM_luk3c26x-dBOVUY62fpo%22%3B%7D'
    'HTTP_ACCEPT_LANGUAGE' => 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7'
    'HTTP_ACCEPT_ENCODING' => 'gzip, deflate'
    'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8'
    'HTTP_USER_AGENT' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36'
    'HTTP_UPGRADE_INSECURE_REQUESTS' => '1'
    'HTTP_CACHE_CONTROL' => 'max-age=0'
    'HTTP_CONNECTION' => 'keep-alive'
    'HTTP_HOST' => 'arm.local'
    'REDIRECT_STATUS' => '200'
    'SERVER_NAME' => 'arm.local'
    'SERVER_PORT' => '80'
    'SERVER_ADDR' => '127.0.0.1'
    'REMOTE_PORT' => '42354'
    'REMOTE_ADDR' => '127.0.0.1'
    'SERVER_SOFTWARE' => 'nginx/1.10.3'
    'GATEWAY_INTERFACE' => 'CGI/1.1'
    'REQUEST_SCHEME' => 'http'
    'SERVER_PROTOCOL' => 'HTTP/1.1'
    'DOCUMENT_ROOT' => '/var/www/arm'
    'DOCUMENT_URI' => '/api/web/index.php'
    'REQUEST_URI' => '/api/v1/users/user-settings?key=wagons-array-user-settings'
    'SCRIPT_NAME' => '/api/web/index.php'
    'CONTENT_LENGTH' => ''
    'CONTENT_TYPE' => ''
    'REQUEST_METHOD' => 'GET'
    'QUERY_STRING' => 'args'
    'SCRIPT_FILENAME' => '/var/www/arm/api/web/index.php'
    'FCGI_ROLE' => 'RESPONDER'
    'PHP_SELF' => '/api/web/index.php'
    'REQUEST_TIME_FLOAT' => 1527274732.2266
    'REQUEST_TIME' => 1527274732
]

Url 管理员配置:

'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'enableStrictParsing' => false,
    'rules' => [
        '/settings' => '/settings',
        '/<action>' => '/site/<action>',
        '/<controller>' => '/<controller>/<action>',
        '/<controller>/<action>' => '/<controller>/<action>',
        '/<module>/<action>' => '/<module>/default/<action>',
        [
            'class' => 'yii\rest\UrlRule',
            'controller' => [
                # some controllers 
                'v1/users/user-groups',
                'v1/users/user-settings',
            ],
            'pluralize'=>false
        ],
    ],
]

nginx 配置部分

location /api/ {
    root /var/www/arm/api/web;
    try_files $uri /api/web/index.php?args;
}

我还在我的 nginx 日志文件中看到这些行:

2018/05/25 21:56:21 [error] 27040#27040: *74 FastCGI sent in stderr: "PHP message: PHP Warning:  Invalid argument supplied for foreach() in /var/www/arm/vendor/yiisoft/yii2/helpers/BaseArrayHelper.php on line 123" while reading response header from upstream, client: 127.0.0.1, server: arm.local, request: "GET /api/v1/users/user-settings?key=wagons-array-user-settings HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "arm.local"
2018/05/25 21:58:52 [error] 27040#27040: *80 FastCGI sent in stderr: "PHP message: PHP Warning:  Invalid argument supplied for foreach() in /var/www/arm/vendor/yiisoft/yii2/helpers/BaseArrayHelper.php on line 123" while reading response header from upstream, client: 127.0.0.1, server: arm.local, request: "GET /api/v1/users/user-settings?key=wagons-array-user-settings HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "arm.local"

备注 它是在将 yii2 更新为 2.0.15.1 和 php 7.2.5 后开始的。
我尝试降级到 php7.2.3,问题仍然存在。
生产版本我的应用程序使用 yii2 v2.0.13 和 php 7.2.3 我没有这个问题。
如果我将 yii2 版本降级到 2.0.13,我会得到这个错误:

yiisoft/yii2-gii 2.0.7 requires yiisoft/yii2 ~2.0.14 -> satisfiable by yiisoft/yii2[2.0.x-dev]

响应。如果我尝试将 yiisoft/yii2-gii 降级到 v2.0.0,我会收到此错误:

The requested package yiisoft/yii2-gii (locked at 2.0.7, required as 2.0.0) is satisfiable by yiisoft/yii2-gii[2.0.7]

服务器 nginx + php-fpm
Yii 版本 2.0.15.1
php 版本 7.2.5-1
nginx 版本 1.10

有人有什么想法吗?

您的 nginx 配置有错字,您在 args 之前错过了 $:

location /api/ {
    root /var/www/arm/api/web;
    try_files $uri /api/web/index.php?$args;
}