Facing issues with Laravel's IoC and Singleton.
I have the following singleton class:
class ConcreteClass
{
function __construct() {Log::info('I iz created...');}
}
And the following service provider:
class ConcreteClassServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->singleton('ConcreteClass', function () {
return new ConcreteClass();
});
}
}
However with every App::make('ConcreteClass'), public function __construct(ConcreteClass $concrete) in a single request will cause the log to have a I iz created... which makes it highly doubtful the singleton thing works in Laravel. I am most probably wrong with the configuration. Please help me with it. Thank you.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire