【问题标题】:getting error like:- [Symfony\Component\Console\Exception\RuntimeException] Too many arguments得到类似的错误:- [Symfony\Component\Console\Exception\RuntimeException] 参数太多
【发布时间】:2016-07-24 21:09:46
【问题描述】:

这是我的 UserCreateCommand.php 文件,当命令:- php artisan user-create username password 出现如下错误:- [Symfony\Component\Console\Exception\RuntimeException] 参数太多。

class UserCreateCommand extends Command
{
/**
 * The name and signature of the console command.
 *
 * @var string
 */
protected $signature = 'user-create';

/**
 * The console command description.
 *
 * @var string
 */
protected $description = 'Create user with password imediately';

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

/**
 * Execute the console command.
 *
 * @return mixed
 */
public function handle()
{
    //
    $username=$this->argument('username');
    $password=$this->argument('password');
    $user= new UserDemo();
    $user->username=$username;
    $user->password=Hash::make($password);
    $user->save();
    $this->info('user has been cretaed');
}
}

【问题讨论】:

  • 命令出错:php artisan user-create username password

标签: laravel laravel-5.2


【解决方案1】:
public function handle()
{
    //
    $username=$this->ask('username');
    $password=$this->secret('password');
    $user= new UserDemo();
    $user->username=$username;
    $user->password=Hash::make($password);
    $user->save();
    $this->info('user has been cretaed');


}

使用命令时工作正常:- php artisan user-create

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-18
    • 2019-10-17
    • 2015-04-17
    • 1970-01-01
    • 1970-01-01
    • 2019-03-01
    • 1970-01-01
    • 2021-04-28
    相关资源
    最近更新 更多