<?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!");
    }
}

<?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!");
    }
}
Make it, you know, actually clear the cache
Make it, you know, actually clear the cache
