gpt4 book ai didi

php - slim 3 : how to access settings?

转载 作者:可可西里 更新时间:2023-10-31 22:08:46 24 4
gpt4 key购买 nike

在 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'];
}

但发布后,我得到以下错误:

Notice: Undefined property: Slim\App::$settings in /...

所以我不能再使用 $app->settings 了?那我该用什么?

最佳答案

您可以获得这样的设置:

$container = $app->getContainer();
$settings = $container->get('settings');

关于php - slim 3 : how to access settings?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34281244/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com