logo
Ask your Symfony questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$40
Symfony and PHP-cli are using different php.ini, trouble with timezone

See the attached screenshot to see the error that I am getting.

I am developing locally on my Mac. I "sudo su" to root, and then, with a text editor, I change:

/private/etc/php.ini

I add in the timezone. This filters though to /etc/php.ini.

I then do "cat /etc/php.ini" and I see this:

;;;;;;;;;;;;;;;;;;;                                                                                                       
; Module Settings ;
;;;;;;;;;;;;;;;;;;;

[CLI Server]
; Whether the CLI web server uses ANSI color coding in its terminal output.
cli_server.color = On

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Europe/London

; http://php.net/date.default-latitude
;date.default_latitude = 31.7667

; http://php.net/date.default-longitude
;date.default_longitude = 35.2333

; http://php.net/date.sunrise-zenith
;date.sunrise_zenith = 90.583333

; http://php.net/date.sunset-zenith
;date.sunset_zenith = 90.583333


So the timezone is set. But I get an error. I have tried both adding and removing quotes around the timezone. It makes no difference.

I am running Nginx and php-fpm. I know this php.ini file is in use since I needed to adjust the path to the "apc.so" extension, and editing this file fixed the problem.

I am joining a team that is working on a Symfony 2.0 project that has been partially upgraded to 2.1 (mostly upgraded in its use of composer.phar).

Any thoughts why I get this error?

ErrorException: 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. 



This question has been answered.

attachment image asker uploaded image

Lawrence Krubner | 05/20/13 at 9:40am Edit
Tutorial: How to assign prize money

Previous versions of this question: 05/20/13 at 9:42am

(20) Responses

See a threaded view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    05/20/13
    9:48am
    anxious says:

    Are you sure you are editing the right php.ini file ?

    check via : php --ini , does it output /private/etc/php.ini or something else ?

    Also, add double quotes for the value, like "Europe/London" .... even if you have the feeling that it's not changing a thing.

    Be sure to restart your webserver after any modification of php.ini

    Previous versions of this answer: 05/20/13 at 9:48am

  • avatar
    Last edited:
    05/20/13
    10:46am
    Pawel Dawczak says:

    Hi,

    Probably your server uses different php.ini file. You can check which one is used with

    phpinfo();
    like here:

    http://screencast.com/t/1QgtZG5EI

    Best regards.

    You can create simple php file, like this:

    <?php

    phpinfo();


    Put it in your projects web folder, open it with your browser. Then you'll see similar output to screenshot I posted eariler.

    This will tell you, which php.ini is loaded by your web server, which may be different for CLI and WebServer.

    Hope it helped.

    Sorry, I don't have experience with Ngix, but little investigation resulted with:

    Link 1 and Link2.

    I'm not sure if any of this will help - I don't have such environment to check this, but answers look reasonable.

    ====

    Please check this:

    link

    Previous versions of this answer: 05/20/13 at 10:10am | 05/20/13 at 10:24am | 05/20/13 at 10:46am

  • avatar
    Last edited:
    05/20/13
    9:51am
    Ahsanul Chowdhury says:

    It may be an issue with your php.ini. Please do the following:

    From the fllowing:

    [Date]
    ; Defines the default timezone used by the date functions
    ; http://php.net/date.timezone


    date.timezone = Europe/London

    Make it look like this:

    [Date]                                                                                           
    date.timezone = Europe/London


    Which means just remove the ";"s. and restart apache.

  • avatar
    Last edited:
    05/20/13
    10:36am
    Arturo Linares says:

    This is not a solution but more a work around that might let you work in your project while you figure out what's wrong. If you don't need apc and nginx you could use the bundled web server with php 5.4:

    $ php -c /etc/php.ini -S localhost:8000 -t web

    -c makes sure you're using the correct php.ini
    -S starts the web server on http://localhost:8000/app_dev.php
    -t the web server entry dir

    Hope this helps.

  • avatar
    Last edited:
    05/20/13
    1:39pm
    Luis Cordova says:

    did you restart php-fpm? all processes must be killed

  • avatar
    Last edited:
    05/20/13
    10:01am
    Lawrence Krubner says:

    Restart my webserver? I am running Nginx. The PHP runs as FastCGI. I don't think "restart the web browser" has any meaning here. That would be a useful idea if I was running Apache/mod_php.

  • avatar
    Last edited:
    05/20/13
    10:02am
    Lawrence Krubner says:

    Maybe it is the php.ini, or maybe it is some internal config. I notice if I do this:

    grep -iR "time_zone" exo-service


    I get:

    exo-service/app/cache/dev/appDevDebugProjectContainer.php:                    'time_zone' => 'America/New_York',
    exo-service/app/cache/dev/appDevDebugProjectContainer.php: 'time_zone' => 'Europe/London',
    exo-service/app/cache/dev/appDevDebugProjectContainer.php: 'time_out_booking.providers.opentable_london.time_zone' => 'Europe/London',
    exo-service/app/cache/dev/appDevDebugProjectContainer.php: 'time_out_booking.providers.opentable_ny.time_zone' => 'America/New_York',
    exo-service/app/cache/dev/appDevDebugProjectContainer.xml: <parameter key="time_zone">America/New_York</parameter>
    exo-service/app/cache/dev/appDevDebugProjectContainer.xml: <parameter key="time_zone">Europe/London</parameter>
    exo-service/app/cache/dev/appDevDebugProjectContainer.xml: <parameter key="time_out_booking.providers.opentable_london.time_zone">Europe/London</parameter>
    exo-service/app/cache/dev/appDevDebugProjectContainer.xml: <parameter key="time_out_booking.providers.opentable_ny.time_zone">America/New_York</parameter>
    exo-service/app/config/config.yml: time_zone: 'America/New_York'
    exo-service/app/config/config.yml: time_zone: 'Europe/London'
    exo-service/app/config/config_common_dev.yml: time_zone: 'America/New_York'
    exo-service/app/config/config_common_dev.yml: time_zone: 'Europe/London'
    exo-service/app/config/search_indexer.yml: site_time_zones:
    exo-service/src/Hotel_Safari/Bundle/BookingBundle/DependencyInjection/Hotel_SafariBookingExtension.php: $container->setParameter( 'time_out_booking.providers.opentable_london.time_zone', $config[ 'providers' ]['opentable_london']['time_zone'] );
    exo-service/src/Hotel_Safari/Bundle/BookingBundle/DependencyInjection/Hotel_SafariBookingExtension.php: $container->setParameter( 'time_out_booking.providers.opentable_ny.time_zone', $config[ 'providers' ]['opentable_ny']['time_zone'] );
    exo-service/src/Hotel_Safari/Bundle/BookingBundle/Provider/Handler/OpenTableHandler.php: $dateTimeZone = !empty( $config[ 'time_zone' ] ) ? $config[ 'time_zone' ]: \date_default_timezone_get();
    exo-service/src/Hotel_Safari/Bundle/BookingBundle/Resources/config/services.xml: <argument type="string" id="timeZone">%time_out_booking.providers.opentable_london.time_zone%</argument>
    exo-service/src/Hotel_Safari/Bundle/BookingBundle/Resources/config/services.xml: <argument type="string" id="timeZone">%time_out_booking.providers.opentable_ny.time_zone%</argument>
    exo-service/src/Hotel_Safari/Bundle/SearchIndexerBundle/DependencyInjection/Configuration.php: ->arrayNode('site_time_zones')
    exo-service/src/Hotel_Safari/Bundle/SearchIndexerBundle/DependencyInjection/Hotel_SafariSearchIndexerExtension.php: \array_map(function ($m) { return $m['site']; }, $config['site_time_zones']),
    exo-service/src/Hotel_Safari/Bundle/SearchIndexerBundle/DependencyInjection/Hotel_SafariSearchIndexerExtension.php: \array_map(function ($m) { return $m['timezone']; }, $config['site_time_zones']));

  • avatar
    Last edited:
    05/20/13
    10:05am
    Lawrence Krubner says:

    This is a headache if true:

    Configuration File (php.ini) Path
    /usr/local/etc/php/5.4

    Loaded Configuration File
    /usr/local/etc/php/5.4/php.ini


    but the webserver, Nginx, is using:

    /etc/php.ini

    How do I get Symfony to use the same php.ini as Nginx?

  • avatar
    Last edited:
    05/20/13
    10:06am
    Lawrence Krubner says:

    I am not using Apache, nor am I using mod_php. I am using Nginx. The PHP is running as Fast CGI.

  • avatar
    Last edited:
    05/20/13
    10:09am
    Lawrence Krubner says:

    Sorry, I should re-phrase that. Nginx has no awareness of PHP. But PHP on the command line, and at startup, is using this file:

    /etc/php.ini

    I have this in the file:

    extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/apc.so

    extension=memcache.so


    PHP was giving me an error on startup, saying that it could not find the file "apc.so". So I had to specify the path. And then the error went away. So PHP on the command line is certainly drawing from this file. I was able to adjust this file and see the results right away.

    But Symfony is using a different PHP config. Anyway to get them to use the same php.ini file?

    I suppose I could edit both php.ini files, but that seems fragile, like a disaster waiting to happen.



  • avatar
    Last edited:
    05/20/13
    10:38am
    Lawrence Krubner says:

    Uploading screenshot.

    attachment image expert uploaded image

  • avatar
    Last edited:
    05/20/13
    10:39am
    Lawrence Krubner says:

    Checkout this error in the screenshot

    attachment image expert uploaded image

  • avatar
    Last edited:
    05/20/13
    10:42am
    Lawrence Krubner says:

    If I open:

    /usr/local/etc/php/5.4/php.ini

    then I see:

    [Date]
    ; Defines the default timezone used by the date functions
    ; http://php.net/date.timezone
    date.timezone = "Europe/London"


    See screenshot.



    attachment image expert uploaded image

  • avatar
    Last edited:
    05/20/13
    10:43am
    Lawrence Krubner says:

    Just for the hell of it I restarted Nginx and cleared the cache. I am still getting this error. Any thoughts?

  • avatar
    Last edited:
    05/20/13
    10:45am
    Lawrence Krubner says:

    Interesting thought. Gave me another thought: restart fpm.

  • avatar
    Last edited:
    05/20/13
    10:54am
    Lawrence Krubner says:

    Ah, damn. This is turning into a royal pain:

     /usr/sbin/php-fpm restart


    gives me:

    [20-May-2013 06:49:56] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/apc.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/apc.so, 9): Symbol not found: _zend_interned_strings_restore
    Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20090626/apc.so
    Expected in: flat namespace
    in /usr/lib/php/extensions/no-debug-non-zts-20090626/apc.so in Unknown on line 0
    [20-May-2013 06:49:56] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/memcache.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/memcache.so, 9): image not found in Unknown on line 0
    Usage: php-fpm [-n] [-e] [-h] [-i] [-m] [-v] [-t] [-p <prefix>] [-g <pid>] [-c <file>] [-d foo[=bar]] [-y <file>]
    -c <path>|<file> Look for php.ini file in this directory
    -n No php.ini file will be used
    -d foo[=bar] Define INI entry foo with value 'bar'
    -e Generate extended information for debugger/profiler
    -h This help
    -i PHP information
    -m Show compiled in modules
    -v Version number
    -p, --prefix <dir>
    Specify alternative prefix path to FastCGI process manager (default: /usr).
    -g, --pid <file>
    Specify the PID file location.
    -y, --fpm-config <file>
    Specify alternative path to FastCGI process manager config file.
    -t, --test Test FPM configuration and exit
    -R, --allow-to-run-as-root
    Allow pool to run as root (disabled by default)

  • avatar
    Last edited:
    05/20/13
    10:59am
    Lawrence Krubner says:

    And this:

     find / -name "libpcre.1.dylib"


    gives me:

    find: /backups/livedbs-dumps/Maildir: Permission denied
    find: /dev/fd/3: Not a directory
    find: /dev/fd/4: Not a directory
    /Users/lkrubner/Downloads/pcre-8.32/.libs/libpcre.1.dylib
    /usr/local/Cellar/pcre/8.32/lib/libpcre.1.dylib
    /usr/local/lib/libpcre.1.dylib
    /usr/local/src/pcre-8.31/.libs/libpcre.1.dylib


    I would like to get apc.so to use:

    /usr/local/src/pcre-8.31/.libs/libpcre.1.dylib

    but I don't know how to do that.

  • avatar
    Last edited:
    05/20/13
    1:40pm
    Luis Cordova says:

    kill all processes fpm

  • avatar
    Last edited:
    05/21/13
    4:50pm
    Lawrence Krubner says:

    "kill all processes fpm"

    why?

  • avatar
    Last edited:
    05/22/13
    3:18pm
    Lawrence Krubner says:

    Killed all fpm processes and started over. That solves half the problem.

This question has expired.



Lawrence Krubner voted on this question.



Current status of this question: Completed



Please log in to add additional discourse to this page.





Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.