Laravel 4 Laravel 4 artisan命令未看到绑定
我创建了一个名为AttachUsers的命令。当我运行命令时,我得到Laravel 4 Laravel 4 artisan命令未看到绑定,laravel-4,Laravel 4,我创建了一个名为AttachUsers的命令。当我运行命令时,我得到 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
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();
}
您可能正在调用Artisan::add(新MyCommand)
。每当您使用“new”关键字时,IoC容器都会被完全绕过,自动依赖项注入将不起作用。相反,可以使用Artisan::add(App::make('MyCommand'))
或简称Artisan::resolve('MyCommand')