2 years ago

Binding many singleton is harmful ?

Posted 2 years ago by hsntngr

I'm trying to do repository pattern and binding all repositories in RepositoryServiceProvider. When a http request started, do all singleton binding again and again ? And is it harmful, is slow down the application ?

 public function register()

        $this->app->singleton(IGameRepository::class,function ($app){
          return new GameCacheRepository((new GameEloquentRepository((new Game))));

        $this->app->singleton(IUserRepository::class,function ($app){
            return new UserCacheRepository((new UserEloquentRepository((new User))));

        $this->app->singleton(IArticleRepository::class,function ($app){
            return new ArticleCacheRepository((new ArticleEloquentRepository((new Article))));

Please sign in or create an account to participate in this conversation.