php - 如何使用 composer.phar install 解决问题

标签 php date symfony datetime

我正在尝试将 composer install 与 symfony2 一起使用。但是我一次又一次地遇到这个问题。

当我运行时:

php composer.php install

我收到以下我不知道如何修复的错误:

错误 #1

[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 setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /Applications/MAMP/htdocs/ffss/vendor/jms/serializer-bundle/JMS/SerializerBundle/DependencyInjection/Configuration.php line 66

错误#2

Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception

错误#3

[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.

这是第一个错误中提到的文件的第 66 行:

->scalarNode('default_timezone')->defaultValue(date_default_timezone_get())->end()

  1. 我不知道在哪里设置它请求的时区。
  2. 我什至不知道从哪里开始修复这个错误:Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
  3. 这是什么意思:执行“'cache:clear --no-warmup'”命令时发生错误。

感谢您的帮助!

最佳答案

只需在您的 app/AppKernel.php 文件中设置默认时区,如下所示:

  <?php

    use Symfony\Component\HttpKernel\Kernel;
    use Symfony\Component\Config\Loader\LoaderInterface;

    // setting the default time zone
    date_default_timezone_set('UTC');


    class AppKernel extends Kernel
    {
       // what ever bundles registered
     }

    public function registerContainerConfiguration(LoaderInterface $loader)
    {
    $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
    }
 }

关于php - 如何使用 composer.phar install 解决问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24621623/

相关文章:

python - 如何计算日期列表中的连续天数

sql - 如何在sql中选择一年中的某一天

php - NelmioApiDocBundle 不生成文档

php - Silex 安全提供商

php - 导入 .sql 文件时出现 Codeigniter "Query was empty"错误

javascript - API调用后的 Angular 回调

PHPUnit 不安装可执行脚本

c# - 将 SQL 日期转换为 dd-mmmm-yyyy C#

php - 如何使我的存储库区分后端/前端

javascript - 如何将 ajax 结果输出到 php 变量中?