简体   繁体   中英

Laravel 4 - Repository Interface not found

Just started working through laracasts and trying to move on from direct eloquent use in the controllers.

I have implemented everything that I need to but hitting this error:

Class tva\Repositories\VehicleRepositoryInterface does not exist

My folder structure is:

app/
  tva/
    repositories/

VehiclesController:

use tva\Repositories\VehicleRepositoryInterface;

class VehiclesController extends \BaseController {
  protected $vehicle;

  public function __construct(VehicleRepositoryInterface $vehicle)
  {
    $this->vehicle = $vehicle;
  }

}

In the repositories folder:

VehicleRepository:

namespace tva\Repositories;

class VehicleRepository implements VehicleRepositoryInterface {
}

VehicleRepositoryInterface:

namespace tva\Repositories;

interface VehicleRepositoryInterface {
}

And also updated my composer.json:

"psr-0": {
  "tva": "app/"
},

To me, this should work?

问题已解决,而不是使用psr-0,我将目录添加到了classmap中,所有问题均已解决。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM