This is just for educational purpose. I am trying to reach my container settings file.
have a container class that gets requested class' constructor parameters(for the moment).
$container->register($className) function pushes data into an array.
Here is my container settings(conf.php) file:
require_once("./app/central/layer/items.php");
$container = new App\Central\Layer\Items;
$container->register("BlaBla_1");
$container->register("BlaBla_2");
Purpose: I want to integrate this configuration file to somewhere i can reach easily from every class.
I don't want to call again and again everytime i try to reach container. I tried something like this.
$containerLoader->loadConfig();
BUT the result is an **empty**
array.(when i'm trying to call from somewhere on another class)
It only works with:
class SomeClass
{
public function __construct()
{
require_once("./conf.php");
// I GET BLABLA_1'S CONSTRUCTOR PARAMATERS WITHOUT ANY PROBLEM
$container->get("BlaBla_1");
}
//other methods...
}
I want to know how can i reach my settings file without doing this. I think that i am doing this in a very wrong way i guess. Any implementation ideas?
Any help would be very appreciated. Thanks anyway.