I'm working on creating custom console in which i have to add code that will check php is executable using below class. If PHP executable then which PHP version is executable.
SyncCommand.php
namespace Soft\Multi\Console\Command;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Shell;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputOption;
use Exception;
use Magento\Framework\App\Filesystem\DirectoryList as DirectoryList;
use Magento\Store\Model\StoreManagerInterface as StoreManagerInterface;
use Magento\Framework\App\State as AppState;
use Symfony\Component\Process\PhpExecutableFinder as PhpExeFinderFactory;
class SyncCommand extends Command
{
protected function execute(InputInterface $input, OutputInterface $output)
{
//accepting results of $pathToCallPHP variable as php71, php, php73 etc...
$pathToCallPHP = $this->_phpExecutableFinder->getData();
}
}
di.xml
<type name="Magento\Framework\Console\CommandList">
<arguments>
<argument name="commands" xsi:type="array">
<item name="syncCommand" xsi:type="object">Soft\Multi\Console\Command\SyncCommand</item>
</argument>
</arguments>
</type>