li3中设置多个连接时无适配器设置异常

No adapter set exception when setting multiple connections in li3

我试图在我的 li3 项目中设置多个连接,但是当我这样做时,我遇到了一个未捕获的异常。我在 app/confi/bootstrap/connections.php 文件中设置连接,然后由 bootstrap.php 文件加载。这是我的联系方式:

 Connections::add('default', array(
    'development' => array(
            'type' => 'MongoDb',
            'host' => 'localhost',
            'database' => 'web_app'
    ),
    'test' => array(
        'type' => 'MongoDb',
        'host' => 'localhost',
        'database' => 'test_web_app'
    )
)
);

当我这样设置并尝试浏览到我的项目时,我收到此错误:

 Fatal error: Uncaught exception 'lithium\core\ConfigException' with message 'No adapter set for configuration in class `lithium\data\Connections`.' in /var/www/site/libraries/lithium/core/Adaptable.php:233

但是,当我只有一个默认连接设置时,它工作正常。还有其他人 运行 处理过这个问题吗?

--更新-- 我从异常中查看堆栈跟踪,发现问题是由我在文件 app/config/bootstrap/user.php 中设置的过滤器引起的,然后由 bootstrap.php[=13 加载=]

这是我的 user.php 文件的样子:

use app\models\Users;
use lithium\security\Password;

Users::applyFilter('save', function($self, $params, $chain) {
if ($params['data']) {
    $params['entity']->set($params['data']);
    $params['data'] = array();
}
if (!$params['entity']->exists()) {
    $params['entity']->password = Password::hash($params['entity']->password);
}
return $chain->next($self, $params, $chain);
});

根据堆栈跟踪,错误来自该文件的第 21 行。第 21 行唯一的内容是 });所以我仍然不确定为什么会导致错误。

看来我被 Li3 误导了 Simple Authentication user tutorial. In their tutorial it has you create a user.php file in the bootstrap directory and has the filter logic in this file (Exactly what I had). However it seems this is not the best way to go about it, especially when using multiple connections as it will throw the exception above. I have moved the filter logic to my Users model file in app/models/Users.php and no longer get the exception. This is the same type of setup that Gavin Davies uses in his Li3 Authentication example