2

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>
0

You need to check outputin console $output->writeln($pathToCallPHP) I hope it's working for you.

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();
             $output->writeln($pathToCallPHP);     
    }
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.