我在我的项目中使用Doctrine2.4.6(不是使用Symfony)。我需要清除缓存元数据,但当我执行该命令时:
cd /home/folder/public_html/includes/doctrine
php vendor/doctrine/orm/bin/doctrine orm:clear-cache:metadata我发现了一个错误:
PHP Warning: php_uname() has been disabled for security reasons in /home/folder/public_html/includes/doctrine/vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutput.php on line 111
[LogicException]
Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI.
orm:clear-cache:metadata [--flush]这里出什么问题了?我可以通过PHP代码编写一些太清晰的缓存吗?
发布于 2015-02-05 16:14:18
您的问题是,即使存在该命令,也无法从命令行清除缓存。为了解决这个问题,我实现了这个脚本(从另一个脚本中复制,所以我现在找不到答案)。
在命令行中这样做: clear_cache_cli.php
$url = 'https://YOURDOMAINENAMEHERE/apc_clear.php'; //use domain name as necessary
$result = file_get_contents($url);
$result_json = json_decode($result);
if (isset($result_json['success']) && $result_json['success'])
{
echo 'Cache borrada!';//handle success
exit(0);
} else {
echo 'Error!';
var_dump($result);//handle failure
exit(1);
}在您的web服务器中:
<?php
if (in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1','YOUR_WEB_SERVER_IP','')))
{
apc_clear_cache();
apc_clear_cache('user');
apc_clear_cache('opcode');
echo json_encode(array('success' => true));
}
else
{
die('SUPER TOP SECRET');
}希望这能有所帮助!
https://stackoverflow.com/questions/26838883
复制相似问题