CakePHP 3 组件 - 正在清除请求数据或查询

CakePHP 3 Component - Request Data or Query being Cleared

我遇到过需要帮助的问题。我不明白为什么会这样。

我正在 CakePHP 中创建一个组件,它拦截传递给 /users/login 的数据,并根据参数对其进行操作。然而,问题是,当数据到达那里时,它是空的。还要注意的是,它在远程机器和本地机器上都运行良好。当我使用 Composer 将此插件上传到另一个站点时,问题开始出现。请问是不是Composer安装插件到vendor目录下的问题

这是我在组件 startup method

中的代码
public function initialize(array $config)
{
    // ....

    $this->Controller = $this->_registry->getController();

    // ...
}

public function startup(Event $event)
{
    // Here I try to get the [test] parameter that is pass in url
    // http://www.domain.com/users/login?test=testing
    $test = $this->Controller->request->query('test');    
}

如果我尝试使用 debug($this->Controller->request);startup(Event $event) 中打印控制器请求,我会得到以下数组:

object(Cake\Network\Request) {
    params => [
        'plugin' => null,
        'controller' => 'Users',
        'action' => 'login',
        '_ext' => null,
        'pass' => [],
        'isAjax' => false
    ]
    data => []
    query => []
    url => 'users/login'
    base => ''
    webroot => '/'
    here => '/users/login'
    trustProxy => false
    [protected] _environment => [
        'SCRIPT_FILENAME' => '/var/www/domain.com/website/webroot/index.php',
        'SCRIPT_NAME' => '/index.php',
        'REQUEST_URI' => '/users/login?test=testing',
        'DOCUMENT_URI' => '/index.php',       

REQUEST_URI 清楚地表明正在通过 test

什么可能导致 CakePHP 在使用 Composer 安装时不接受 test 参数?为什么 params['pass'] => []data => []query => [] 是空的?

经过几个小时的努力,我 8 岁的女儿不得不为我指出正确的方向。一个简单但浪费时间、令人头疼的错误导致了所有问题。问题出在我的 NGINX 配置文件中。

我有以下内容:

location / {
    try_files $uri $uri/ /index.php$args;
}

但我应该有以下内容:

location / {
    try_files $uri $uri/ /index.php?$args;
}

因为我在 index.php 之后省略了 ?,NGINX 根本不接受在 url.

中传递的任何参数

经验教训!