I've got a problem with Symfony 2.3, I can't get it to work to get a custom function that handles the fatal errors. The Symfony exceptions work fine, like a 404 etc. but a fatal error not.
This is what I've got after searching the internet, I've a created a parent controller in the TestBundle. The other default controller extends the TestingSomeThingController. Se the files below for the code. But when I deleted the ; at the end of the line in DefaultController it's shows the standard fatal error page instead of the "yaay" I put in the code. Does anyone have got an answer for this question? Thanks!
TestingSomeThingController
<?php
namespace TestingSomeThing\TestBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller as BaseController;
use Symfony\Component\HttpFoundation\Response;
class TestingSomeThingController extends BaseController
{
public function __construct()
{
set_error_handler(array($this, 'sdfg'));
register_shutdown_function(array($this, 'sdfg'));
}
public function sdfg()
{
$error = error_get_last();
if(isset($error)) {
echo 'yaay';
die();
}
}
}
DefaultController
<?php
namespace TestingSomeThing\TestBundle\Controller;
use TestingSomeThing\TestBundle\Controller\TestingSomeThingController;
class DefaultController extends TestingSomeThingController
{
public function indexAction($name)
{
return $this->render('TestingSomeThingBundle:Default:index.html.twig', array('name' => $name))
}
}