Some time ago I had installed Apache+MySQL using MacPorts in Mac OS X. It was all OK as long as I used the web browser to navigate thru the web pages, but as I runned PHP via CLI to execute Symfony2 commands I started having problems. It said for example that my time zone was not set, and I knew for sure that I had configured it in the php.ini
file.
$ php app/console doctrine:schema:update --force
[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. In case you used any of those me thods and you are still getting this warning, you most likely misspelled th e timezone identifier. We selected 'Europe/Berlin' for 'CET/1.0/no DST' ins tead in /Users/enekochan/Documents/Webs/este.es/vendor/monolog/monolog/src/ Monolog/Logger.php line 199
Searching the web for a solution I realized that the problem was that I was running the binary php that comes with Mac OS X, and I didn’t have the timezone configured for it. You can see where the php.ini
file is by running this:
$ php -i | grep 'Configuration File'
Configuration File (php.ini) Path => /etc
Loaded Configuration File => (none)
The first solution i came up with was to use the full path for the MacPorts php binary file:
$ /opt/local/bin/php app/console doctrine:schema:update --force
$ /opt/local/bin/php -i | grep 'Configuration File'
Configuration File (php.ini) Path => /opt/local/etc/php5
Loaded Configuration File => /opt/local/etc/php5/php.ini
A better solution consists on adding to the systems path /opt/local/bin
before /usr/bin
. This can be done adding this to ~/.bash_profile
:
PATH=/opt/local/bin:$PATH;export PATH
Then you have to close and open a new terminal or source the newly edited ~/.bash_profile
:
$ source ~/.bash_profile
Ref: Stackoverflow