所以这可能很容易,但我已经四处走动了几个小时。错误消息
Illuminate ' Container ' BindingResolutionException
Target [foo'repositories'OrderRepositoryInterface] is not instantiable.
我的界面:
<?php namespace foo'repositories;
interface OrderRepositoryInterface
{
public function index(array $dateRange = null, $customerId = null);
}
存储库:
<?php namespace foo'repositories;
use Carbon'Carbon;
use Order;
class OrderRepository implements OrderRepositoryInterface
{
public function index(array $dateRange = null, $customerId = null)
{
return 'HI';
}
}
我的路线文件:
App::bind('foo'repositories'OrderRepositoryInterface.php',
'foo'repositories'OrderRepository.php');
Route::resource('orders', 'OrdersController');
最后是控制器:
<?php
use foo'repositories'OrderRepositoryInterface;
class OrdersController extends 'BaseController
{
protected $order;
/**
* @param OrderRepositoryInterface $order
*/
public function __construct(OrderRepositoryInterface $order)
{
$this->order = $order;
}
public function index()
{
$orders = $this->order->index();
return $orders;
}
在App::bind
中绑定时,尝试从接口和存储库中删除.php更多关于此处绑定
App::bind('foo'repositories'OrderRepositoryInterface',
'foo'repositories'OrderRepository');