<?php

namespace Ob\CacheNukeBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\HttpFoundation\Response;

class NukeController extends Controller
{
    public function indexAction()
    {
        $command = new CacheClearCommand();
        $command->setContainer($this->container);

        $input = new ArrayInput(array());
        $output = new NullOutput();

        // The @ is kinda bad, but there always was a "Warning: ini_set(): A session is active."
        // Which caused the response to be a 500.
        @$command->run($input, $output);

        return new Response("Cache Nuked!");
    }
}
<?php

namespace Ob\CacheNukeBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\HttpFoundation\Response;

class NukeController extends Controller
{
    public function indexAction()
    {
        $kernel = $this->get('kernel');
        $app = new Application($kernel);
        $app->setAutoExit(false);

        $input = new StringInput('cache:clear --env=prod');
        $output = new NullOutput();

        $app->run($input, $output);

        return new Response("Cache Nuked!");
    }
}

--- 
+++ 
@@ -3,8 +3,8 @@
 namespace Ob\CacheNukeBundle\Controller;
 
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
-use Symfony\Component\Console\Application;
-use Symfony\Component\Console\Input\StringInput;
+use Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand;
+use Symfony\Component\Console\Input\ArrayInput;
 use Symfony\Component\Console\Output\NullOutput;
 use Symfony\Component\HttpFoundation\Response;
 
@@ -12,14 +12,15 @@
 {
     public function indexAction()
     {
-        $kernel = $this->get('kernel');
-        $app = new Application($kernel);
-        $app->setAutoExit(false);
+        $command = new CacheClearCommand();
+        $command->setContainer($this->container);
 
-        $input = new StringInput('cache:clear --env=prod');
+        $input = new ArrayInput(array());
         $output = new NullOutput();
 
-        $app->run($input, $output);
+        // The @ is kinda bad, but there always was a "Warning: ini_set(): A session is active."
+        // Which caused the response to be a 500.
+        @$command->run($input, $output);
 
         return new Response("Cache Nuked!");
     }
Make it, you know, actually clear the cache
