Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Config in config file

Tags:

laravel

It is possible to reference another Config variable within a configuration files?

Something like this config/app.php

'user' => Config::get('mail.user'),
like image 398
Yada Avatar asked Apr 17 '15 15:04

Yada


People also ask

What is the use of config file?

A configuration file, often shortened to config file, defines the parameters, options, settings and preferences applied to operating systems (OSes), infrastructure devices and applications in an IT context. Software and hardware devices can be profoundly complex, supporting myriad options and parameters.

What is the use of config file in Python?

Config files are used to store key value pairs or some configurable information that could be read or accessed in the code and at some point, of time.

How parse config file in Python?

The configparser module has ConfigParser class. It is responsible for parsing a list of configuration files, and managing the parsed database. Return all the configuration section names. Return whether the given section exists.

How do I open a config file?

To open a CFG file using the native Notepad app, open Windows File Explorer at the location of the file. If Windows automatically recognizes the CFG file, double-click it to open it in Notepad. Alternatively, right-click the CFG file and select the Open With option.


1 Answers

No, as far as I know this isn't possible in the way you suggested. As mentioned in the other questions you should do that by using you're environment file.

I suggest you do this in a service provider. To me it sounds like you're doing something what isn't actually not a configuration thing. I think you better can do it this way:

As you can see in the documentation of the configuration repository there is a set method on the config repository. So do it like this in a service provider:

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

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

like image 161
ArjanSchouten Avatar answered Oct 28 '22 16:10

ArjanSchouten