l5-repository icon indicating copy to clipboard operation
l5-repository copied to clipboard

BindingResolutionException

Open Andreypinky opened this issue 7 years ago • 6 comments

I have installed and configured everything.

When i am trying to create Route with Controller / any Class method, i have got this error Illuminate \ Contracts \ Container \ BindingResolutionException Target [App\Repositories\SubscriptionRepository] is not instantiable while building [App\Http\Controllers\SubscriptionsController]. ... throw new BindingResolutionException($message); ...

Routes `

// this works
Route::get('/test', function(){
	return view('test_view');
});

// and this one is NOT
Route::get('test', 'TestsController@test'); // here we return our test_view

1 - this causes memory leak -> App\Providers\AppRepositoryProvider in app.php 2 - composer update 3 - composer dumautoload 4 - php artisan clear-compiled 5 - php artisan chache:clear 6 - checked binding, i am not pro, but it seems to be ok $this->app->bind(\App\Repositories\TestRepository::class, \App\Repositories\TestRepositoryEloquent::class);

Also, in Laravel 5.4 was changed Trait name.

Andreypinky avatar Mar 03 '17 11:03 Andreypinky

the same error when I implement for Restful API as: "errors": { "message": "Target [App\Repositories\RolesRepository] is not instantiable while building [\App\Http\Controllers\RolesController]." }

and in my RepositoryServiceProvider.php: $this->app->bind(\App\Repositories\RolesRepository::class, \App\Repositories\RolesRepositoryEloquent::class);

Any help? I'm using Laravel 5.4

shincha3517 avatar Mar 20 '17 03:03 shincha3517

I'm also having issues with this as well. I followed the installation and configuration process but may be I missed something.

I already added the necessary class in my "config/app.php" as well as already created the bindings to a repository but it seems like its not working for me as its throwing "BindingResolutionException".

I'm using Laravel 5.4

Defrothew avatar Mar 24 '17 00:03 Defrothew

Ok, I fixed my issue because I missed a step.

I just added this code to my "app\Providers\AppServiceProvider"'s register method function: $this->app->register(RepositoryServiceProvider::class);

Defrothew avatar Mar 24 '17 00:03 Defrothew

@Andreypinky This might help you out. https://github.com/andersao/l5-repository/issues/546#issuecomment-447570311

vrkansagara avatar Dec 15 '18 15:12 vrkansagara

I met this issue when i deploy to production enviroment. public function register() { if ($this->app->environment() == 'local') { $this->app->register(RepositoryServiceProvider::class); } } So my solution is change "local" -> "production" public function register() { if ($this->app->environment() == 'production') { $this->app->register(RepositoryServiceProvider::class); } }

acerjt avatar Jul 21 '20 01:07 acerjt

Ok, I fixed my issue because I missed a step.

I just added this code to my "app\Providers\AppServiceProvider"'s register method function: $this->app->register(RepositoryServiceProvider::class);

i did this and work now... thank you!

romualdo6 avatar Jun 01 '21 14:06 romualdo6