Support the ongoing development of Laravel.io →
IOC Forms Validation
Last updated 2 years ago.
0

IN your service provider,

$app->make('RocketCandy\Repo\Job\JobInterface')

...isn't resolving to anything because you haven't (as far as I can see) told Laravel what class you want to implement that interface.

You need to make a second $app->bind() call for the interface to tell Laravel what class to use when the JobInterface is type hinted in the constructor function.

$app->bind('RocketCandy\Repo\Job\JobInterface', function($app)
        {
            return 'Return a new class which implements JobInterface';
        });
Last updated 9 years ago.
0

Many thanks Chris. The issue was actually in my RepoServiceProvider file (page 40 in your book). I'd attempted to implement the interface but rather unsuccessfully:

use Job;
use RocketCandy\Repo\Job\EloquentJob;
use Illuminate\Support\ServiceProvider;

class RepoServiceProvider extends ServiceProvider {

    public function register()
    {
        $app = $this->app;
        $app->bind('RocketCandy\Repo\Job\JobInterface', function($app)
        {
            $job =  new EloquentJob(
                new Job
            );
        });
    }
}

Foolishly I should have have been RETURNING new EloquentJob instead of using the $job variable. Highly embarrassing but thanks for you help!

0

Sign in to participate in this thread!

Eventy

Your banner here too?

olimorris olimorris Joined 31 Dec 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.