2

So this is probably an easy one but I've been going around for hours. The error message

Illuminate \ Container \ BindingResolutionException
Target [foo\repositories\OrderRepositoryInterface] is not instantiable.

My interface:

<?php  namespace foo\repositories;

interface OrderRepositoryInterface
{

 public function index(array $dateRange = null, $customerId = null);

}

The repository:

<?php  namespace foo\repositories;
use Carbon\Carbon;
use Order;

class OrderRepository implements OrderRepositoryInterface
{


public function index(array $dateRange = null, $customerId = null)
{
    return 'HI';

}


} 

my routes file:

App::bind('foo\repositories\OrderRepositoryInterface.php',
          'foo\repositories\OrderRepository.php');


Route::resource('orders', 'OrdersController');

and finally the controller:

<?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;
}
Casey
  • 1,941
  • 3
  • 17
  • 30
  • [Does this post offer any insight](http://stackoverflow.com/questions/15236878/laravel-4-target-interface-is-not-instantiable)? – bishop Apr 26 '14 at 14:06
  • 1
    Try to remove the .php from both the interface and the repository when you bind them in App::bind – Paul Bele Apr 26 '14 at 14:08
  • @seblaze son of a ... Yup, that was it. Hours I spent on this thing. If you put that in a answer I'll mark it correct. Thank You! – Casey Apr 26 '14 at 14:12
  • @Casey Made a response , so other people can know about this :) I'm glad i could be of help – Paul Bele Apr 26 '14 at 14:13

1 Answers1

2

Try to remove the .php from both the interface and the repository when you bind them in App::bind More about binding here

App::bind('foo\repositories\OrderRepositoryInterface',
          'foo\repositories\OrderRepository');
Paul Bele
  • 1,514
  • 1
  • 11
  • 12