流明:打印自定义配置返回NULL [英] Lumen: print custom config return NULL

查看:154
本文介绍了流明:打印自定义配置返回NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将配置目录放置在应用程序的根目录中:

I placed the configuration directory in the application root:

/config/app.php

/config/app.php

/config/app.php的内容:

Contents of /config/app.php:

<?php

return [
    'test' => 'this config should work',
];

在/bootstrap/app.php中:

In the /bootstrap/app.php:

$app->configure('app');

要测试:

dd(config('app.test'));

结果为NULL :(.我该如何解决? 我发现github上存在相同的问题( https://github.com/laravel/lumen-framework/issues/107 ),但我已经在最新版本中更新了Lumen.

Result is NULL :(. How can I fix it? I see that there is the same issue on github (https://github.com/laravel/lumen-framework/issues/107) but I have already updated my Lumen at the last version.

推荐答案

在bootstrap.php文件中添加此

In your bootstrap.php file add this

collect(scandir(__DIR__ . '/../config'))->each(function ($item) use 
($app) {
        $app->configure(basename($item, '.php'));
});

这篇关于流明:打印自定义配置返回NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆