无法解决未定义的索引:第252行/vendor/slim/slim/Slim/App.php中的outputBuffering错误

时间:2016-02-28 22:24:18

标签: slim slim-3

我正在关注Destructy教程,在设置和测试数据库连接后,我收到以下错误:

到目前为止,这是我的设置:

fixed

这是容器的定义方式:

  begin
    page.driver.browser.navigate.to("about:blank")
    page.driver.browser.switch_to.alert.accept
  rescue Selenium::WebDriver::Error::NoAlertPresentError
    # No alert was present. Don't need to do anything
  end

路线:

return [
    'settings' => [
        'displayErrorDetails' => true,
    ],
    'url'   =>  'http://localhost',
    'db'    =>  [
        'mysql' =>  [
            'host'      =>  'localhost',
            'dbname'    =>  'destructy',
            'username'  =>  'username',
            'password'  =>  'password',
            'charset'   =>  'utf8',
            'collation' =>  'utf8_unicode_ci',
            'prefix'    =>  '',
        ]
    ],
];

有人知道问题是什么来修复它吗?

1 个答案:

答案 0 :(得分:1)

您无法使用点语法访问配置值,应该类似于:

$container['db'] = function($c){
    $conf = $c->db;
    return new PDO(
        'mysql:host='.$conf['mysql']['host'].';dbname='.$conf['mysql']['dbname'],
        $conf['mysql']['username'],
        $conf['mysql']['password'];
};