l5-repository
l5-repository copied to clipboard
BindingResolutionException
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.
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
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
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);
@Andreypinky This might help you out. https://github.com/andersao/l5-repository/issues/546#issuecomment-447570311
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); } }
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!