I'm trying to create a package and need to validate that the credentials are loaded from the config file each time an instance is created. This is because I'm going to pass the $config variable in the package constructor.
So, in my package service provide class I have the register function and in that I'm using the following code:
// Register the service the package provides.
$this->app->singleton('mypackage', function($app) {
die(' 49');
$config = $app['config']->get('mypackage');
if(!$config){
throw new \RuntimeException('missing mypackage configuration section');
}
if(!isset($config['TARGETBRANCH'])){
throw new \RuntimeException('missing mypackage configuration: `API`');
}
return new Mypackage($config);
});
As you can see that I have a "die" as the first action in the singleton, so I'm expecting to see "49" in the browser where I am calling the instance but the singleton isn't called and I get straight to the package class.
In the class I have the constructor as:
public function __construct($config){
dd($config);
}
What could be possibly be going wrong here? Any help would be really appreciated.
Thank you