2014-03-06 1 views
3

AttachUsers라는 명령을 만들었습니다. 내가 명령을 실행할 때 나는 Laravel 4 숙련공이 바인딩을 인식하지 못함

Argument 1 passed to AttachPhones::__construct() must be an instance of Acme\\Repositories\\Organizations\\OrganizationRepositoryInterface, none given, called in \/Users\/jonson\/sites\/acme\/app\/start\/artisan.php on line 5 and defined","file":"\/Users\/jonson\/sites\/acme\/app\/commands\/AttachPhones.php","line":30}} 

내가 저장소 서비스 공급자 파일 내 인터페이스를 결합하고 그것이 현재 나의 컨트롤러에서 워킹됩니다

를 얻을. 내 명령 파일은 다음과 같습니다.

<?php 
use Illuminate\Console\Command; 
use Symfony\Component\Console\Input\InputOption; 
use Symfony\Component\Console\Input\InputArgument; 
use \Acme\Repositories\Organizations\OrganizationRepositoryInterface; 

class AttachUsers extends Command { 

protected $organizations; 

/** 
* The console command name. 
* 
* @var string 
*/ 
protected $name = 'acme:attach_users'; 

/** 
* The console command description. 
* 
* @var string 
*/ 
protected $description = 'Cron command to attach users from import to organizations'; 

/** 
* Create a new command instance. 
* 
* @return void 
*/ 
public function __construct(OrganizationRepositoryInterface $organizations) 
{ 
    $this->organizations = $organizations; 

    parent::__construct(); 
} 

답변

1

아마 Artisan::add(new MyCommand)입니다. "new"키워드를 사용할 때마다 IoC 컨테이너는 완전히 무시되고 자동 종속성 주입은 이 아니며이 작동합니다. 대신 Artisan::add(App::make('MyCommand')) 또는 축약어 인 Artisan::resolve('MyCommand')을 사용하십시오.

+2

나는 그것을 시도했지만 아무런 효과가 없었다. – user3061986

관련 문제