In my application I'm using the Symfony/Console package (v. 3.2.7) and I created several commands that works fine.
Now I'm trying to automate some tasks and I added in the composer.json scripts sections
"scripts": {
"test": [
"@php app/console myproject:setup"
]
}
And the code in the command is
<?php
namespace MyProject\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
/**
* Class SetupCommand
* @package WpSkeletonCLI\Command
*/
class SetupCommand extends Command
{
protected function configure()
{
$this->setName('myproject:setup');
$this->setDescription('A setup wizard for your brand new skeleton based project.');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->getHelper('question')->ask($input, $output, new ConfirmationQuestion('Are you displaying this question?', false));
}
}
If I run the command from console, it works fine, but if I run the command in the same way from composer it doesn't work, it displays no errors and the question is not showed. I tried to add print command just to know if the command is call properly and I can see all my print examples (both methods).
I red also the scripts section on Composer, the only thing I noticed is that I'm not using the Composer Event object.
Maybe the Symfony Question Helper is not compatible with running script from Composer?