laravel - 我的命令如何通过可选参数传递给另一个 Artisan 命令?
问题描述
(更新的问题表明它不像链接的问题)
我编写了一个 Laravel 命令(如下所示),它基本上是 Dusk 的包装器,因此我可以确保事先调用某些其他函数。(否则,我不可避免地会忘记重置我的测试环境。)
当我运行时它完美运行php artisan mydusk
。
namespace App\Console\Commands;
class DuskCommand extends BaseCommand {
protected $signature = 'mydusk {file?} {--filter=?}';
protected $description = 'refreshAndSeedTestingDb, then run Dusk suite of tests';
public function handle() {
$this->consoleOutput($this->description);
$resetTestingEnv = new ResetTestingEnv();
$resetTestingEnv->refreshAndSeedTestingDb();
$this->consoleOutput('refreshAndSeedTestingDb finished. Now will run Dusk...');
$file = $this->argument('file');//What to do with this?
return \Artisan::call('dusk', ['--filter' => $this->option('filter')]);
}
}
如您所见,我已经阅读了这些文档并了解如何编写$signature
以接受可选参数。
我的目标是有时能够运行php artisan mydusk
,并且还能够有选择地添加参数,例如当我可能想要调用类似的东西时php artisan mydusk tests/Browser/MailcheckTest.php --filter testBasicValidCaseButtonClick
(这会将tests/Browser/MailcheckTest.php --filter testBasicValidCaseButtonClick
参数传递给普通dusk
命令)。
如何编辑handle()
函数的最后两行以便$file
传递给dusk
?
解决方案
推荐阅读
- php - PDOConnection.php 第 24 行 Laravel 5.3 中的 FatalThrowableError
- node.js - Firebase 存储-如何使用 node.js 从存储中删除文件?
- android - 认证成功后再次开启指纹服务
- javascript - 事件不适用于使用 Snap.svg 制作的 SVG
- php - 如何合并两个数组?
- reactjs - 是否可以在 react-native 的 TextInput 中设置 textalign left 但 placeholder right
- php - codeigniter 中所有页面通用的动态标题菜单
- c# - 使用 Yahoo 发送电子邮件时出现 SMTP 异常
- dart - 有没有办法从一个依赖于另一个 API 的 API 获取数据
- redis - Redis 中是否存在只读连接?