In Symfony, when we run a command, if there are any notifications or warnings, Symfony displays a large red message and exits the entire program.
I want an error to be logged, but I do not want the entire program to terminate. Can someone please tell me how to do this. thanks.
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class NotQuitWithWarningOrNoticeCommand extends ContainerAwareCommand { protected function configure() { $this ->setName('try:nored') ->setDescription('Avoid to show big red message') ->addArgument('type'); } protected function execute(InputInterface $input, OutputInterface $output) { $type = $input->getArgument('type'); if ($type == 'warning' || !$type) { trigger_error("a warning", E_USER_WARNING); } if ($type == 'notice' || !$type) { trigger_error("a notice", E_USER_NOTICE); } echo "Hi there!\n"; } }
(The code here is just to reproduce the problem. Getting a warning or notification is my script.)
source share