在执行“";cache:clear-无预热”";命令


An error occurred when executing the ""cache:clear --no-warmup"" command

我是php和symphony的新手。我正在尝试使用composer安装一些php包。我得到这个错误:

脚本Sensio''Bundle''DistributionBundle''Composer''ScriptHandler::clearCache处理安装后cmd事件以异常终止

[RuntimeException]执行"cache:clear-无预热"命令:

[Symfony'Component'Debug'Exception'ContextErrorException]
Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the

date.timezone设置或date_default_timezone_set()函数。在里面如果你使用了这些方法中的任何一种,但你仍然得到这个wa
rning,您很可能拼错了时区标识符。我们暂时选择了时区"UTC",但请将date.timezone设置为选择您的时区。

关于是什么原因导致的?

这是因为php.ini没有定义默认时区。要使更改服务器独立,您可以通过向AppKernel.php内的AppKernel类添加以下代码来轻松解决该问题:
public function __construct($environment, $debug)
    {
        date_default_timezone_set('Europe/Berlin');
        parent::__construct($environment, $debug);
    }

其中Europe/Berlin是您的时区。一旦完成,在发出任何命令之前,您必须至少加载一次页面,以便AppKernel类构造函数至少运行一次。之后,您可以运行正确的命令,它应该可以正常工作。