4

I am trying to use composer install with symfony2. But I keep running into this issue time and again.

When I run:

php composer.php install

I get the following errors that I do not know how to fix:

Error #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

Error #2

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

Error #3

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

This is line 66 of the file mentioned in the 1st error:

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

  1. I dont know where to set the time zone it is requesting.
  2. I dont know where to begin to even fix this error: Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
  3. What does this even mean: An error occurred when executing the "'cache:clear --no-warmup'" command.

Thanks for your help!

LargeTuna
  • 2,694
  • 7
  • 46
  • 92
  • Fixing the timezone will probably fix the rest of those errors, which are a chain reaction from the initial exception. http://stackoverflow.com/questions/16765158/date-it-is-not-safe-to-rely-on-the-systems-timezone-settings-in-codeigniter – Michael Berkowski Jul 07 '14 at 23:46
  • This is the line in my php.ini file with the timezone setting: date.timezone = "Europe/Berlin" . it is uncommented. Not sure why symfony is requesting this when it already exists. – LargeTuna Jul 07 '14 at 23:58
  • Composer executes via PHP CLI. On many systems, the CLI uses a _different_ php.ini than the web. Check `php -i` as suggested below to make sure you're looking at the right php.ini. – Michael Berkowski Jul 08 '14 at 00:00
  • I have changed every php.ini file on my system to now have date.timezone = UTC, but I still get the errors. – LargeTuna Jul 08 '14 at 00:14

3 Answers3

5

just set the default timezone in in your app/AppKernel.php file like this:

  <?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');
    }
 }
Czechnology
  • 14,832
  • 10
  • 62
  • 88
Ajeet Varma
  • 726
  • 4
  • 20
1

Please run php -i and grab the location of the mentioned php.ini file in the output. That file needs the setting mentioned in the error message added. There probably already is some commented line with this name.

All other errors are triggered by the first one and shouldn't be triggered once the required PHP setting is done.

Sven
  • 69,403
  • 10
  • 107
  • 109
  • This is that line: date.timezone = "Europe/Berlin" – LargeTuna Jul 07 '14 at 23:48
  • What should that tell me now? You added the line and it works? You found that line and wonder why it's already there? – Sven Jul 07 '14 at 23:50
  • 1
    It wans't commented out, it was active when i ran "php composer.phar install". I dont know why I am getting the original error because my php.ini file has the date.timezone setting in place. get it now? I dont. I dont know why Symfony is telling me to use a setting that is already in place. – LargeTuna Jul 07 '14 at 23:54
1

Found the solutions on this post: Link to the solution

I tried to edit everyone one of the php.ini files on my system and restart apache/MAMP, no success.

This is the only thing that I could get to work.

Community
  • 1
  • 1
LargeTuna
  • 2,694
  • 7
  • 46
  • 92
  • Restarting Apache will do nothing because you are not using the PHP contained in there, but a completely standalone PHP version, the CLI version (command line interface). This PHP does use a different php.ini file than the Apache PHP, because there might be a need to configure them differently. You didn't convince me that you know about this and edited the correct file. – Sven Jul 08 '14 at 17:48