2017-06-29 5 views
1

versuche ich die folgenden Codes verwenden Cache von Web-Art und Weise klar, aber ich habe die Antwort-Nachricht:Probleme, wenn in symfony-Controller Aktion-Methode Cache klar Befehl

// Löschen des Cache für die Umwelt dev mit debug // true [Symfony \ Komponente \ Debug \ Exception \ ContextErrorException] Warnung: ini_set(): eine Sitzung ist aktiv. Sie können die Sitzung modu le's ini Einstellungen zu diesem Zeitpunkt nicht ändern cache: clear [--no-warmup] [--no-optional-warmers] [-h | --help] [-q | --quiet] [ -v | vv | vvv | --verbose] [-V | --version] [--ansi] [--no-ansi] [-n | --no-interaktion] [-e | -env ENV] [--no-debug] [-]

Mein Code ist wie folgt:

/** 
* @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: meine php.ini session.auto_start => Aus => Aus

+0

Ich versuche es so, es funktioniert! '$ input = new ArrayInput ([ 'Befehl' => 'Cache: löschen', '--env' => 'dev', '--no-warmup' => wahr ]);' –

+0

Übernehmen Ihre Antwort, erklären was falsch war. – COil

+0

Ich lese documnet (https://symfony.com/doc/current/reference/dic_tags.html#kernel-cache-clearer) # Neu in Version 3.3: Ab Symfony 3.3, der Warm-up-Teil des Caches: Der Befehl clear ist veraltet. Sie müssen immer die Option --no-warmup an den Cache übergeben: löschen und stattdessen cache: warmup verwenden, um den Cache aufzuwärmen. –

Antwort

0
public function cacheClearAction() 
{ 
    $application = new Application($this->get('kernel')); 
    $application->setAutoExit(false);//exit after run 
    $input = new ArrayInput([ 
     'command' => 'cache:clear', 
     '--env' => 'dev', 
     '--no-warmup' => true 
    ]); 
    $output = new BufferedOutput(); 
    $runCode = $application->run($input, $output); 
    $content = $output->fetch(); 
    return new Response($content); 
}