I've made a Contract interface and an Eloquent Repository for my application but I'm getting a 500 error when I try to use it.
I have a feeling it has something to do with the way it is registered. To do this with a service provider which has the following register
method:
/**
* Register service provider bindings
*/
public function registerBindings() {
$this->app->bind(
\App\Repositories\Backend\EventContract::class,
\App\Repositories\Backend\EloquentEventRepository::class
);
}
I then use the contract as follows in my controller:
class EventController extends Controller {
/**
* @var EventContract
*/
protected $events;
/**
* EventController constructor.
* @param EventContract $events
*/
public function __construct(EventContract $events)
{
$this->events = $events;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view('backend.events.index')
->withEvents($this->events->getEventsPaginated(25, 1));
When I load the page with the 500 error there's no entry in the Laravel logs or the Nginx logs (I use Homestead with Vagrant).
Any idea? Thanks in advance
EDIT: Found some logs!
2016/02/17 09:47:52 [error] 1868#0: *331 FastCGI sent in stderr: "inate\Container\Container->make() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:674
PHP message: PHP 478. Illuminate\Container\Container->build() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Container/Container.php:633
PHP message: PHP 479. Illuminate\Container\Container->getDependencies() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Container/Container.php:779
PHP message: PHP 480. Illuminate\Container\Container->resolveClass() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Container/Container.php:808
PHP message: PHP 481. Illuminate\Foundation\Application->make() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Container/Container.php:853
PHP message: PHP 482. Illuminate\Container\Container->make() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:674
PHP message: PHP 483. Illuminate\Container\Container->build() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Container/Container.php:633
PHP message: PHP 484. Illuminate\Container\Container->Illuminate\Container\{closure}() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Container/Container.php:735
PHP message: PHP 485. Illuminate\Foundation\Application->make() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Container/Container.php:230
PHP message: PHP 486. Illuminate\Container\Container->make() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:674
PHP message: PHP 487. Illuminate\Container\Container->build() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Container/Container.php:633
PHP message: PHP 488. Illuminate\Container\Container->getDependencies() /home/vagrant/Code/Yoosit/vendor/laravel/framework/src/Illuminate/Container/Container.php:779
PHP message: PHP 489. Illuminate\Container\Container->resolveClass() /home
May be stupid pointers, but no harm checking:
Double check the namespace in respective files i.e. EventContract and EloquentEventRepository class files.
Check if you have imported the namespace in the EventController if not using full path
After registering service provider did you run composer dump-autoload -o
Try using chrome devtools to see the response if debug is on