kernel); $application->setAutoExit(false); error_reporting ( E_ALL & ~E_DEPRECATED & ~E_STRICT); $input = new ArrayInput([ 'command' => 'zitec:action:execute', // (optional) define the value of command arguments 'action' => $action, 'condition' => $condition, 'userid' => $userId, ]); file_put_contents ( 'action.log' , 'zitec:action:execute '. $action.' '.$condition.' '.$userId , FILE_APPEND ); error_reporting(E_ERROR | E_WARNING | E_PARSE); // You can use NullOutput() if you don't need the output $output = new BufferedOutput(); $application->run($input, $output); // return the output, don't use if you used NullOutput() $content = $output->fetch(); if($this->getParameter('kernel.environment')=='prod'){ if(json_decode($content, true)['route'] ||json_decode($content, true)['error']) return $content; } $content=explode("\n",$content); $lastelement=null; foreach($content as $contenido){ if (!is_array($contenido)){ if(json_decode($contenido, true)['route'] ||json_decode($contenido, true)['error']) $lastelement= $contenido; }else{ if(json_decode(end($contenido), true)['route'] ||json_decode(end($contenido), true)['error']) $lastelement= end($contenido); } } // if(!empty($content)) // die(print_r($content,true)); return $lastelement;//$content;//[count($content)-2]; } }