1
votes

I am new to repository in laravel and trying to work on it , But when i run the application it throws the error

Class 'App\Repositories\User\UserRepoServiceProvider' not found

My interface and repository files are located in App\Repositories\User where Service Provider is also located

Here is my service provider

namespace App\Repositories\User

use Illuminate\Support\ServiceProvider;

class UserRepoServiceProvider extends ServiceProvider

{

public function register()
{

$this->app->bind('App\Repositories\User\userinterface','App\Repositories \User\userrepository');
}
}

Here is my userrepository.php

namespace App\Repositories\User

use App\Repositories\User\userinterface;
use App\car;

class userrepository implements userinterface
{

public function __construct(car $car){

$this->car = $car;
}

public function get($id)
{

return $this->car->findCar($id);
}

public function delete($id)
 {

return $this->car->deleteCar($id);
}


}

Here is my interface userinterface.php

namespace App\Repositories\User;

interface userinterface{

public function get($id);

public function delete($id);
}

I have also registered it in config/app.php file

App\Repositories\User\UserRepoServiceProvider::class

I did composer dump-autoload -o but no use. I cannot do composer update , when i do it throws the same error

3
Try deleting the cached files. rm bootstrap/cache/*. Then run composer install again. - alariva
May I know what changes it does to the application ? - Naveen Kumar
Sure, first ls that dir to see which files will you delete. Those are cached versions that may have out of date contents. Plust, it does not actually change your app behavior. They will get regenerated automatically when needed. If in doubt just backup the files first. - alariva
No use , its still the same - Naveen Kumar

3 Answers

3
votes

I usually check in bootstrap/cache/config.php for the package, sometimes after composer remove nameofthepackage, the package is still listed there

1
votes

You have to register the service provider in config/app.php. https://laravel.com/docs/5.3/providers#registering-providers

0
votes

I'm facing this problem Class 'App\Respositories\BackendServiceProvider' not found It was due to spelling mistake in config/app.php file. I changed Respositories to Repositories and open this BackendServiceProvider and changed namespace also. so problem has been solved.

Respositories to Repositories
namespace App\Respositories to namespace App\Repositories;