#Adding config files/folders?

11 messages · Page 1 of 1 (latest)

violet ravine
#

Hi. Is there any way extra config files/folders with config files can be added(similar to f.ex console commands, perhaps)?

Reason for asking is that there a "core" composer package that is used by our system in multiple other laravel apps. That core package consists of multiple "modules" some of which it seems could benefit from some accompanying config, which would have to be added to laravel. The alternative would be to copy those configs to each of the laravel apps, which of course would be really bad maintenance wise..

violet ravine
#

Adding config files/folders?

versed dew
#

Yes you can add your own configs and reference them. I don't understand the rest of the question though. If your package is across multiple apps, but share the same configuration, why even have a config to begin with? You'd have a config if things differ per Laravel app, which in the end would lead to separate configs and "bad maintenance" as you call it

violet ravine
#

Valid point. I imagine it's easiest to have settings in one place though, trying to fill in fields the usual way using env() and the .env file of that particular app, instead of adding the config of a module to each app having to keep track of those places as the code in the module evolves..

I think it's easiest to edit those settings in the .env. Some values might differ between apps using the same module, say f.ex APP_URL or something. URLs might differ between dev and prod environments too, I guess. Probably(hopefully) a one-time job to edit them.

Can you elaborate on how to add and reference configs, how do I make Laravel aware of them if they're not located in the normal config folder?

versed dew
#

If it's a package, wouldn't you just publish a config to the default config dir? You can do what the default configs do and reference env variables within those configs as well

#

Otherwise I am not really following what the issue is with your module approach

violet ravine
#

Currently there's a config folder in the module.

A similar(?) thing is done to support console commands in a module without having to copy them to the normal app/Console/Commands folders of the apps, there's a "bootstrap" file for the core package, if the module's commands is added there the apps using the core package loads those commands since we've added some code to the apps to run that bootstrap file. ( I hope that was readable, but I'm not sure)

The plan has been to tell laravel about the module configs similar to those console commands being added to app/Console/Kernel.php.

But if you have a better way then I'm all grateful ears. You mean publish as in artisan publish? I haven't done things that way before, so I don't know much about it. Would it be something like php artisan core:publish, as in a normal console command? ..which would then be placed somewhere in the core package?

violet ravine
#

Ok, reading up on vendor:publish and packages

versed dew
#

Yes it would be publishing vendor files into the Laravel app itself. I haven't personally done a module approach before so it's hard for me to follow what kinda thing you're dealing with

violet ravine
dapper flame
#

Sounds like you just need to call mergeConfigFrom() in the module service providers.