@SergioGregorutti I think you are using the Illuminate\Config\Repository namespace, use the Facade instead:
use Config:
....
..........
Config::get('world.name');
Usman.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi all,
Im using the Configuration Values for setting different database name depending on the domain.
And then, I need to use the variable on the file "config/database.php". But when I call the variable I get this error:
"Deprecated: Non-static method Illuminate\Config\Repository::get() should not be called statically, assuming $this from incompatible context in /home/vagrant/Code/argemundo/config/database.php on line 60"
This is the code:
...
'database' => Config::get('world.name'),
...
How can I use the variable on that file? Or what is the best approach to handle that?
Im seting the variable on the service provider "AppServiceProvider".
Thanks in advance!
@SergioGregorutti did you try:
switch($domain) {
case "http://local.argemundo.com":
............
//mysql for instance.
$config->set('database.connections.mysql.database', 'am_hurlingham');
break;
}
This would work, not sure if this suits your needs.
Please or to participate in this conversation.