Since you are defining this env variable you should alter this config file. There are 2 arguments passed to env
here and all of them must be resolved as they are being passed to a function. This is before the function even runs, so it doesn't matter if that env variable exists that file_exists
call will happen no matter what.
You can remove the expression which uses file_exists
as its unneeded in your case since you are setting the env variable.
env('USER_MODEL', 'some sane default?');
This is fine since you are supposed to publish this config file so its in your application config, so you control it at this point.
Part 2
Now that your version of the config file is fixed we don't want the package's config file to be merged since it will still try to do this file_exists
call every time. To do this we will extend their provider and override the register
method. Then we will add your version of their provider to the providers list and also tell the auto discovery system to ignore this package (so it doesn't register its provider or alias):
app/Providers/SomeCoolNamedProvider
:
namespace AppProviders;
use SilvaniteBrandenburgProvidersBrandenburgServiceProvider;
class SomeCoolNamedProvider extends BrandenburgServiceProvider
{
public function register()
{
// in their version they merge the config here
// but we don't want that, so leave this blank
}
}
config/app.php
:
$providers = [
...
AppProvidersSomeCoolNamedProvider::class,
];
$aliases = [
...
'BrandenburgPolicy' => SilvaniteBrandenburgFacadesPolicyFacade::class,
];
composer.json
:
"extra": {
"laravel": {
"dont-discover": [
"silvanite/brandenburg"
]
}
},
You can run the auto discovery command after this, php artisan package:discover
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…