关于php:在Lumen中覆盖composer软件包的配置文件

Overriding configuration files of composer packages in Lumen

我有一个安装了外部Composer软件包的Lumen项目。与Lumen一样,它们存储在vendor目录中,每个目录都位于各自的文件夹中。其中一些软件包具有配置文件,我想用自定义文件覆盖这些文件。

我在注册应用程序本身之后立即使用$app->configure()bootstrap/app.php中注册了文件,所以看起来像这样:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
require_once __DIR__ . '/../vendor/autoload.php';

try {
    (new Dotenv\\Dotenv(__DIR__ . '/../'))->load();
} catch (Dotenv\\Exception\\InvalidPathException $e) {
    //
}

$app = new Laravel\\Lumen\\Application(
    realpath(__DIR__ . '/../')
);

$app->withFacades();
$app->withEloquent();

$app->configure('/Configuration/Lumen/app.php');
$app->configure('/Configuration/Lumen/auth.php');
$app->configure('/Configuration/Tymon/jwt.php');

文件位于各自的目录中,并且包含我希望流明使用的设置,而不是分别位于以下位置的默认设置:

1
2
3
/vendor/laravel/lumen-framework/config/app.php
/vendor/laravel/lumen-framework/config/auth.php
/vendor/tymon/jwt-auth/config/config.php

我遇到的问题是在这种配置下,Lumen似乎忽略了我的自定义文件,而是使用默认值。我在这里做错什么了吗?


将配置文件放在config/中,并按文件名在bootstrap/app.php中注册它们,而.php文件不结尾。

1
2
// Your custom config in config/jwt-auth.php
$app->configure('jwt-auth');