In my service provider I bind a class with singleton:
public function register()
{
$this->app->singleton('ResourceContainer', function($app){
return new ResourceContainer();
});
}
The laravel doumentation says that this class will be resolved one time and the same object will be returned:
The singleton method binds a class or interface into the container that should only be resolved one time. Once a singleton binding is resolved, the same object instance will be returned on subsequent calls into the container:
But in my app the constructor of ResourceContainer
is called twice.
I want to call this instance in my boot method of the serviceprovider:
public function boot()
{
$resourceContainer = $this->app->make('ResourceContainer');
And I inject the class in a controller:
public function index(ResourceContainer $container, $resource){
When I debug, the constructor of ResourceContainer is called twice. I get a different object in my controller than in the boot method of the service provider.