I installed fresh Laravel 5 copy.
My detectEnvironment function is defined this way:
$app->detectEnvironment(function()
{
return 'local';
return getenv('APP_ENV') ?: 'production';
});
In config\local
I've created database.php
file:
<?php
return [
'nothing' => 'new',
];
I run php artisan clear-compiled
.
My index
method of WelcomeController
is defined this way:
public function index(Application $app)
{
echo $app->environment();
var_dump($app['config']['database']);
//echo $app['config']['database'];
return view('welcome');
}
Application was imported this way: use Illuminate\Foundation\Application;
The result I get is:
local array(1) { ["nothing"]=> string(3) "new" }
whereas I would expect Laravel to cascade config file with production one (with the default config\database.php
file.
The strange thing is that even if I comment the line return 'local';
run again php artisan clear-compiled
it shows:
production array(1) { ["nothing"]=> string(3) "new" }
so it seems it always loads database.php
file content (this one from local folder) and overrides main database.php
file. It works fine again when I change this file name to for example aaa.php
.
Is it a bug or maybe environment configuration shouldn't be stored inside config
directory? But if not, where should they be store? I don't know if it's a bug or a feature so if anyone knows more about it, please give me a clue.