MAMP / Symfony: MAMP overrides the date.timezone parameter from php.ini, Symfony does not work

I am trying to customize the Symfony2 structure in MAMP.

In php.ini I set date.timezone , however, it seems that MAMP is somehow overriding the setting and is using the system time instead.

As a result, the Symphony config.php page sends this warning:

Warning: date_default_timezone_get () [function.date-default-timezone-get]: it is unsafe to rely on the settings of the system time zone. You must use date.timezone or date_default_timezone_set (). If you used any of these methods and you still get this warning, you most likely mistakenly specified the time zone identifier. We chose 'America / New_York' instead of 'EST / -5.0 / no DST' instead of /Applications/MAMP/htdocs/Symfony/app/SymfonyRequirements.php on line 434

Symfony does not show the start page until it is fixed. What will be the solution?

Thanks!

+4
source share
7 answers

I'm still working on figuring out why and how MAMP overrides php.ini date.timezone settings, however I found a quick fix solution in symfony php files that solved the problem, at least for now.

I added the following bit of code:

 date_default_timezone_set ('America/New_York'); 

- at the top of the Symfony config.php and app_dev.php files, immediately after opening the php tag, at the very top of the script. This removed the warning message and made Symfony work on MAMP.

I predict that you need to add the same code to some other php files inside Symfony, as I continue to crack it, which should not be a problem. Or I can figure out how to override the MAMP override.

However, this is an acceptable solution.

+2
source

Check if there are two php.ini files on your system. You can add the date.timezone line to one of them, but MAMP uses the other.

If this does not help, try adding the following line at the beginning of your web/app.php and web/app_dev.php (as the error message suggests):

 date_default_timezone_get('Europe/London'); 

Hope this helps.

+2
source
  • Copy

cp /etc/php.ini.default /etc/php.ini

  • change permissions

chmod -R 775 /etc/php.ini

  • change

sudo vi /etc/php.ini

  • find date.timezone and change it to (example):

date.timezone = "Europe/London"

+1
source

Are you on the command line? call the command line can get a different php.ini than MAMP.

To find out which of your php.ini from the command line you can do:

 $ php -i | grep 'Configuration File' 

(link: How to find the php.ini file used on the command line? )

Try setting "date.timezone" to "/etc/php.ini" or wherever it says it is your php.ini file.

You can also modify the php.ini file:

 $ php -help | grep "php.ini" -c <path>|<file> Look for php.ini file in this directory 

How...

 $ php -c /Applications/MAMP/conf/php5.5.14/php.ini ... 

For instance:

 $ php -c /Applications/MAMP/conf/php5.5.14/php.ini -i | grep 'Configuration File' 
0
source

If your problem is how to make changes to the php.ini file in MAMP PRO, try editing the template.

File β†’ Edit Template

In the MAMP manual you can find page 24

More info here

0
source

In MAMP 3.0.1, the php.ini file in the corresponding version of the php folders you are using has a date.timezone value, declared after the semicolon, which turns it into a comment and not a command. In php.ini in C: \ MAMP \ conf \ php5.5.12 (or your version of php), remove the semicolon on line 703 and determine your local time as recommended by http://php.net/manual/en/timezones .php .

Hope this works for you :)

0
source

As Pedro Luz mentioned, you should set the time zone in your mac php.ini and not in MAMP.

Remember to restart mac apache:

 sudo /usr/sbin/apachectl restart 

This solution worked for me:

 [OK] Your system is ready to run Symfony2 projects 
0
source

All Articles