0

I've upgraded my laravel app from 4.2 to 5, and I'm getting the following error when trying to inject my dependency:

<?php namespace App\Classes\Api\Zurmo;

  use App\Classes\Api\Rest\ApiRestHelper;

  class Connector implements ConnectorInterface {

  public function __construct(ApiRestHelper $rest)
  {
     ...

Argument 1 passed to App\Classes\Api\Zurmo\Connector::__construct() must be an Instance of App\Classes\Api\Rest\ApiRestHelper, none given

As far as I can see, its looking ok, what am I missing here?

3
  • How do you use this class? Commented May 1, 2015 at 14:29
  • the Connector class above is called from a controller like so: use App\Classes\Api\Zurmo\Connector as Zurmo; Commented May 1, 2015 at 14:40
  • Did you bind your interface to your class-implementation? Commented May 2, 2015 at 12:17

1 Answer 1

2

If you want Laravel to resolve your dependencies automatically you have to instanciate the class through the Service Container:

$zurmo = App::make('App\Classes\Api\Zurmo\Connector');

Or with the app() function:

$zurmo = app('App\Classes\Api\Zurmo\Connector');

Note that you have to write out the full path of the class


Alternatively you could let Laravel inject the connector itself in the controller. For example:

use App\Classes\Api\Zurmo\Connector as Zurmo;

// ...

public function __construct(Zurmo $zurmo){
    $this->zurmo = $zurmo;
}

public function someAction(){
    $this->zurmo->doMagic();
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.