修身3之前被释放,下面做工精细代码:苗条3:如何访问设置?
的settings.php,
return [
'settings' => [
'displayErrorDetails' => true,
'modules' => [
'core' => 'config/core/modules.php',
'local' => 'config/local/modules.php'
],
],
];
的index.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'];
}
但发布后,我得到这个错误如下:
公告:未定义的属性:修身\ APP :: $在设置/ ...
所以我不能用$app->settings
了吗?我应该使用什么?
我不得不包括“全球$ app;”在这些线路之前这为我工作。 –