Use Config in configuration file

Is it possible to refer to another configuration variable in the configuration files?

Something like this config / app.php

'user' => Config::get('mail.user'), 
+6
source share
3 answers

No, as far as I know, this is not possible in the way you suggested. As mentioned in other questions, you should do this using the environment file.

I suggest you do this with your service provider. To me it sounds like you are doing something that is not really a setting. I think you better do this:

As you can see in the documentation in the configuration repository, there is an installed method in the configuration repository. So do it in the service:

 public function boot() { Config::set('app.user',Config::get('mail.user')); } 

Put this in the boot method so that every binding is present in the IoC container.

+1
source

In Laravel 4, you can set variables from another configuration file, but you need to use:

  'url' => \Illuminate\Support\Facades\Config::get('constants.url'), 

instead:

  'url' => Config::get('constants.url'), 
+1
source

Try adding the mail.php file to the / config application directory:

 <?php return array( 'user' => 'username' ); 

And then get the value as you suggested:

 'user' => Config::get('mail.user'), 
0
source

Source: https://habr.com/ru/post/985365/


All Articles