I try use the following codes to clear cache by web way, but I got the response message:
// Clearing the cache for the dev environment with debug // true [Symfony\Component\Debug\Exception\ContextErrorException] Warning: ini_set(): A session is active. You cannot change the session modu le's ini settings at this time cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--]
My code is as follows:
/**
* @Route("/cache/clear", name="cache_clear")
*/
public function cacheClearAction( )
{
$application = new Application($this->get('kernel'));
$application->setAutoExit(false);//exit after run
$input = new ArrayInput([
'command' => 'cache:clear',
'--env' => 'dev',
]);
$output = new BufferedOutput();
$runCode = $application->run($input, $output);
$content = $output->fetch();
return new Response($content);
}
ps:my php.ini session.auto_start => Off => Off
$input = new ArrayInput([ 'command' => 'cache:clear', '--env' => 'dev', '--no-warmup' => true ]);
– X.Sophie