Php laravel 4.2 artisan命令:带参数的名称

Php laravel 4.2 artisan命令:带参数的名称,php,laravel,laravel-artisan,Php,Laravel,Laravel Artisan,我创建了一个artisan命令,名为sendUnreadNotifications。如果用户有未读的通知,该命令将触发系统向用户发送电子邮件。最终,这将通过cron作业运行,用户可以每小时更新,也可以每天更新 出于这个原因,我想用我的命令发送一个论点,类似这样的东西 php artisan command:name sendUnreadNotifications H --env=local <?php use Illuminate\Console\Command; use Symfon

我创建了一个artisan命令,名为sendUnreadNotifications。如果用户有未读的通知,该命令将触发系统向用户发送电子邮件。最终,这将通过cron作业运行,用户可以每小时更新,也可以每天更新

出于这个原因,我想用我的命令发送一个论点,类似这样的东西

php artisan command:name sendUnreadNotifications H --env=local
<?php

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class sendUnreadNotifications extends Command {

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

/**
 * The console command description.
 *
 * @var string
 */
protected $description = 'Command description.';

/**
 * Create a new command instance.
 *
 * @return void
 */
public function __construct()
{
    parent::__construct();
}

/**
 * Execute the console command.
 *
 * @return mixed
 */
public function fire()
{
    $request = Request::create('api/notifications/send/unread', 'GET', array($this->getArguments()));
    Route::dispatch($request)->getContent();
}

/**
 * Get the console command arguments.
 *
 * @return array
 */
protected function getArguments()
{
    return array(
        array('frequency', InputArgument::OPTIONAL, 'How often should the email be sent', 'H'),
    );
}

/**
 * Get the console command options.
 *
 * @return array
 */
protected function getOptions()
{
    return array(
        array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
    );
}
但是运行此命令时,我得到以下错误:

[运行时异常]
争论太多了

我的代码是这样的

php artisan command:name sendUnreadNotifications H --env=local
<?php

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class sendUnreadNotifications extends Command {

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

/**
 * The console command description.
 *
 * @var string
 */
protected $description = 'Command description.';

/**
 * Create a new command instance.
 *
 * @return void
 */
public function __construct()
{
    parent::__construct();
}

/**
 * Execute the console command.
 *
 * @return mixed
 */
public function fire()
{
    $request = Request::create('api/notifications/send/unread', 'GET', array($this->getArguments()));
    Route::dispatch($request)->getContent();
}

/**
 * Get the console command arguments.
 *
 * @return array
 */
protected function getArguments()
{
    return array(
        array('frequency', InputArgument::OPTIONAL, 'How often should the email be sent', 'H'),
    );
}

/**
 * Get the console command options.
 *
 * @return array
 */
protected function getOptions()
{
    return array(
        array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
    );
}

对于
频率

protected function getArguments()

{
    return array(
        array('frequency', InputArgument::OPTIONAL, 'How often should the email be sent', 'H'),
    );
}
那么

php artisan command:name sendUnreadNotifications H --env=local
这里的
H
是一个太多的参数。您应该将命令的名称更改为您想要执行的操作,顺便说一句,命令名称必须是唯一的

更改此项:

protected $name = 'command:name';

和你的同事一起工作

php artisan send:UnreadNotifications H
它会起作用的