我跑的工匠:
php artisan down --message "Going down for maintenance" --retry=60
[更新]或类似@Remul运行它建议:
php artisan down --message="Going down for maintenance" --retry=60
那么这两个给我的错误:
[Symfony\Component\Console\Exception\RuntimeException]
Too many arguments, expected arguments "command".
如果运行像这样没有空格的命令:
php artisan down --message "Going_down_for_maintenance" --retry=60
不会发生错误
我使用PHP 7.0.14
我想通了:
问题实际上是如何PHP是从命令行在供应商/ symfony中/控制台/输入参数获取/ ArgvInput.php我能理解,php收到argfuments是这样的:
0 => "artisan"
1 => "down"
2 => "--message=Going"
3 => "down"
4 => "for"
5 => "maintenance"
6 => "--retry=60"
因此,即使以确保我做了我自己的脚本与此内容:
<?php
var_dump($argv);
我运行它:
php -v;php test_argv.php "parm with space" other_parameter
输出是:
PHP 7.0.14 (cli) (built: Jan 30 2017 15:45:33) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
array(5) {
[0]=>
string(13) "test_argv.php"
[1]=>
string(4) "parm"
[2]=>
string(4) "with"
[3]=>
string(5) "space"
[4]=>
string(15) "other_parameter"
}
我有一个不同版本的PHP运行在其他机器,看看我的结果:
PHP 7.1.5 (cli) (built: Sep 19 2017 10:48:01) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Xdebug v2.5.4, Copyright (c) 2002-2017, by Derick Rethans
array(3) {
[0] =>
string(13) "test_argv.php"
[1] =>
string(15) "parm with space"
[2] =>
string(15) "other_parameter"
}
看起来像在PHP 7.0和7.1 argv的解析是完全不同的,一个忽略了双引号字符串分隔符和更高版本不
此消息中指定的存储/框架/ PHP所人员向下命令向下产生的JSON格式文件可用。
您可以打开该文件,并修改它。
祝好运
这是一个不相关的问题,但这是地方,谷歌发给我,因为我犯了这个错误... ..洙
其他常见的原因,去:
Too many arguments, expected arguments "command".
这就是你所提供的参数,当工匠脚本需要的选项。所以,你需要改变
./artisan yourcommand:yoursubcommand some_kind_of_input
至
./artisan yourcommand:yoursubcommand --an_option=some_kind_of_input
错误只是一般意味着工匠没想到任何此命令的附加参数...