![]() |
|
Snippets |
|
You can mimick the call of the symfony command line via a PHP script called from the browser. For instance, for the command
$ symfony clear-cache
...create a webclearcache.php file in your myproject/web/ directory (where the index.php is) with the following content:
<?php // as we are in the web/ dir, we need to go up one level to get to the project root chdir(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'); include_once('/lib/symfony/pake/bin/pake.php'); $pake = pakeApp::get_instance(); try { $ret = $pake->run('/data/symfony/bin/pakefile.php', 'clear-cache'); } catch (pakeException $e) { print "<strong>ERROR</strong>: ".$e->getMessage(); } ?>
You can now clear the cache by calling:
http://myapp.example.com/webclearcache.php
Note: Beware that by letting web access to administration tools, you can compromise the safety of your website.
Comments on this snippet
I got error with the php script, It work with :
[...] include_once('pake.php'); [...] $pake->run(PEAR_INSTALL_DIR.'/data/symfony/bin/pakefile.php', 'clear-cache'); [...]
Check this out too: http://www.symfony-project.com/snippets/snippet/66 Bye!
Updated to use it from action class and symfony 1.0: