Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rbferreyra's avatar

Config in subdirectory

There are some way the config folder have subdirectory like development, training, etc. ?

According lumen documentation, that is should work.

http://lumen.laravel.com/docs/configuration#configuration-files

"However, you may use full, "Laravel style" configuration files if you wish"

0 likes
3 replies
ixudra's avatar
ixudra
Best Answer
Level 4

The old Laravel 4 system of overriding config based on development environment is no longer functional, it was removed in Laravel 5 because it was incredibly slow. If you want to change the values of certain config options, you need to use environment variables which are stored in the .env file. See config/app.php for some examples

Alternatively, if you want to use subdirectories for additional config: I've never done it with config, but for language files this worked for me in the past: Lang::get('path/to/dir/file.key.subkey');

1 like
oromeroctm's avatar

Just in case someone need it. This is the way I was able to do it:

Step 1 - Create the sub directory under config/ for example validator

Step 2 - Create the configuration files: messages.php, rules.php

config
└── validator
    ├── messages.php
    └── rules.php

Step 3 - Enable the configuration files under bootsrap/app.php

/*
|--------------------------------------------------------------------------
| Register Custom Configuration
|--------------------------------------------------------------------------
|
| Register custom configuration files that are under config/
|
*/
$app->configure('validator/messages');
$app->configure('validator/rules');

/**/
$app->router->group([
    'namespace' => 'App\Http\Controllers',
], function ($router) {
    require __DIR__.'/../routes/web.php';
});

return $app;

Step 4 - Get the configuration

config('validator/rules.key');
2 likes

Please or to participate in this conversation.