S
S
Sergey2015-07-20 10:42:25
symfony
Sergey, 2015-07-20 10:42:25

How to flush cache and update assets from Symfony2 controller?

There is this code in the controller, the purpose of which is to reset the entire cache and update the assets in the prod environment.

public function resetAction()
    {

        $app_path = $this->container->getParameter('kernel.root_dir') . '/console';
        $process = new \Symfony\Component\Process\Process("php $app_path cache:clear --env=prod --no-debug --no-warmup");
        $process->run();

        $process = new \Symfony\Component\Process\Process("php $app_path assets:install");
        $process->run();

        $process = new \Symfony\Component\Process\Process("php $app_path assetic:dump --env=prod --no-debug");
        $process->run();

        return new Response('ok');
    }

The code works successfully, but does not reset the cache (changes are not displayed)
What am I doing wrong and how to do it right?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
BoShurik, 2015-07-20
@karmis

Replace
with
AND it turns out that the code does not work successfully.
Most likely, another php.ini is used.
Compare the output php -iin the console and like this:

$process = new \Symfony\Component\Process\Process("php -i");
$process->run();

return new Response($process->getOutput());

PS And what kind of task is it that you can't clear the cache in the standard way?

D
Denis, 2015-07-20
@prototype_denis

I answered your previous question that your application works in a dev environment.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question