在 Slim 3 发布之前,以下代码可以正常工作:
设置.php,
return [
'settings' => [
'displayErrorDetails' => true,
'modules' => [
'core' => 'config/core/modules.php',
'local' => 'config/local/modules.php'
],
],
];
索引.php
// Instantiate the app
$settings = require __DIR__ . '/../src/settings.php';
$app = new \Slim\App($settings);
$MyClass = new MyClass($app);
MyClass.php
class MyClass
{
private $app;
public function __construct($app)
{
$this->app = $app;
$local = require $app->settings['modules']['local'];
}
但发布后,我在下面收到此错误:
注意:未定义的属性:Slim\App::$settings in /...
那我就不能用$app->settings
了吗?那我应该用什么?