Php 如何将命令的输出作为另一个命令的输入传递?

Php 如何将命令的输出作为另一个命令的输入传递?,php,symfony,stdin,symfony-console,Php,Symfony,Stdin,Symfony Console,我正在使用Symfony控制台应用程序,并尝试将phpstan的输出作为控制台命令的输入: 供应商/bin/phpstan分析| bin/wte分析 当前命令按预期运行,但如何将phpstan的输出传递到bin/wte analysis命令 //AnalyseCommand.php 最终类AnalyseCommand extends命令 { public const NAME='analysis'; /** *@var SymfonyStyle */ 私人$symfonyStyle; 公共功能

我正在使用Symfony控制台应用程序,并尝试将phpstan的输出作为控制台命令的输入:

供应商/bin/phpstan分析| bin/wte分析
当前命令按预期运行,但如何将phpstan的输出传递到
bin/wte analysis
命令

//AnalyseCommand.php
最终类AnalyseCommand extends命令
{
public const NAME='analysis';
/**
*@var SymfonyStyle
*/
私人$symfonyStyle;
公共功能构造(SymfonyStyle$SymfonyStyle)
{
$this->symfonyStyle=$symfonyStyle;
父项::_构造();
}
公共函数执行(InputInterface$input,OutputInterface$output):int
{
//在这里获取phpstan输出。
返回外壳代码::SUCCESS;
}
受保护的函数configure():void
{
$this->setName(self::NAME);
$this->setDescription('Find a error');
}
}

Symfony控制台没有任何处理标准输入的功能。但是它不是必需的,因为您仍然使用PHP,并且可以使用任何

公共函数执行(InputInterface$input,OutputInterface$output):int
{
$stdin='';
而(!feof(STDIN)){
$stdin.=fread(stdin,1024);
} 
//使用$stdin执行您需要的操作
}