I installed MAMP for windows
I have this error since several hours...
[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 me
thods and you are still getting this warning, you most likely misspelled th
e timezone identifier. We selected the timezone 'UTC' for now, but please s
et date.timezone to select your timezone.
In the php.ini concerned (C:/MAMP/conf/php5.5.19/php.ini), I changed the line DATE like this:
[Date]
; Defines the default timezone used by the date functions
date.timezone = "Europe/Paris"
And in my phpinfo(), the path loaded is :
Loaded Configuration File C:\MAMP\conf\php5.5.19\php.ini
When I do in the consol the command php --ini I have this :
C:\Users\Thomas>php --ini
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Why Configuration File (php.ini) Path: is "C:\Windows" and not C:\MAMP\conf\php5.5.19\. Can I change this Path ?
I don't know what to do now...
thanks !
I had the same error. I had no clue where it was coming from, but with some trial and error I figured out it had something to do with the special character in my htdocs folder:
htdocs/Exámple
By changing that character to a normal character (thus changing to htdocs/Example), I no longer got the error and the site would load normally.
The problem is that your xAMP server and cli access uses different php configuration.
One is C:\Windows\php.ini for CLI
Second is C:\MAMP\conf\php5.5.19\php.ini for web server
Make sure you have updated both files.
Secondly do not forget to restart xAMP server, as apache do not reload libapache2-mod-php5 configs automatically.
When you set configuration in MAMP it only affects PHP which is loaded in Apache module handler mode (mapped as module inside Apache process). If you want to set PHP CLI you need to set this separately from web server configuration.
Open command prompt from Windows (cmd.exe from Start button)
enter ECHO %PATH%
this command will list your current PATH variable with all paths. For example, something like this:
C:>echo %PATH%
C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\binaries\php\php_runningversion
;C:\ProgramData\Oracle\Java\javapath;C:\Perl\site\bin;C:\Perl\bin
...
now enter following command
SET PATH=%PATH%;c:\mamp\bin\php\php5.6.0\;
This will going to add path to php5.6.0 version from MAMP folder.
you can now test your PHP CLI by entering following command :
php -v
then try to initialize configuration from MAMP for version PHP5.6.0 file:
C:>php -c "c:\mamp\conf\php5.6.0\php.ini" --ini
Configuration File (php.ini) Path: C:\WINDOWS
Loaded Configuration File: C:\MAMP\conf\php5.6.0\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
You can use command -c from PHP CLI to set path to configuration file; and "c:\mamp\conf\php5.6.0\php.ini" is path to PHP ini file for version 5.6.0.
If you do not want to always add path to configuration file with -c command, just copy php.ini file from C:\MAMP\conf\php5.6.0\ to C:\MAMP\bin\php\php5.6.0\
Off course, this will going to set PHP CLI only in currently opened command prompt. To add this path permanently, you need to modify System Environment variable, or to use MAMP PRO as it already have this feature on PHP options page.
TL:DR - Make sure to edit both the ..\MAMPPRO\conf\php[version].ini and the ..\MAMP\bin\php\php[version]\php.ini with your correct/approved php timezone.
So while I was going through my setup, I had the same issue.
I was taking a look at my phpinfo() and it was giving me a path to my "Loaded Configuration File" that was located in my ..\MAMPPRO\conf\php[version].ini so I was editing that file with approved timezone from http://php.net/manual/en/timezones.php making sure to avoid any from http://php.net/manual/en/timezones.others.php.
After a few restarts and no success I started to dig a little further into where MAMP Pro was pulling that ini.
I found the solution in ..\MAMP\bin\php\php[version]\php.ini. If I edited this file IN ADDITION TO editing the MAMP Pro ini everything worked properly.
Hopefully this can help you out!
At the beggining of your web/app_dev.php and web/app.php you can add:
date_default_timezone_set('Europe/Paris');
Related
I'm getting back in to web development so have decided to re-install my Mac's dev environment from scratch with homebrew (I'm following the tutorial at https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions which is probably the best tutorial on the subject that I've ever read).
Everything is going fine apart from using PECL to install extensions like APCU and Xdebug. I think I can get extensions working in a slightly hacky way, but I'd rather properly understand what's going on here.
My php.ini file is located at /usr/local/etc/php/7.1/php.ini. When PECL installs an extension, it seems to add a line to the top of php.ini immediately above the [PHP] line, e.g.:
1 zend_extension="xdebug.so"
2 extension="apcu.so"
3 [PHP]
4
5 ;;;;;;;;;;;;;;;;;;;
6 ; About php.ini ;
7 ;;;;;;;;;;;;;;;;;;;
8 ; PHP's initialization file, generally called php.ini, is responsible for
9 ; configuring many of the aspects of PHP's behavior.
The tutorial advises going to /usr/local/etc/php/7.1/conf.d/ and creating individual config files for each extension. i.e., lines 1 and 2 in php.ini would be deleted, and /usr/local/etc/php/7.1/conf.d/ext-apcu.ini and /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini would be created, with config settings for each extension included in the relevant ext-xx.ini file.
Neither the default PECL approach of referencing the extension in php.ini nor the recommended approach of using an ext-xx.ini file for each extension seems to load the extensions successfully. I can hack round this by specifying a path to the extensions (/usr/local/lib/php/pecl/somedatestamp/extension.so), but I'd rather not have to. So:
(I'm pretty sure the answer to this is "yes", but just to be sure): does the server just scan through the conf.d folder and try to load any extension.so that is described in every ext-extension.so file it finds?
How do I set the equivalent of $PATH for my PHP configuration? phpinfo() refers to an extension_dir variable and gives the value as /usr/local/Cellar/php#7.1/7.1.20/lib/php/20160303, and there's an extension_dir variable set in php.ini but it's commented out. So where is PHP getting the value it's displaying through phpinfo(), and is it possible to specify multiple directories where PHP will look for extensions?
Server doesn't scan for *.so files automatically, it loads extensions mentioned in php config files in extension=extension.so and zend_extension=extension.so configurations. To check all config files which are loaded during server start run the command php --ini, my example output is:
$ php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/7.1
Loaded Configuration File: /usr/local/etc/php/7.1/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.1/conf.d
Additional .ini files parsed: /usr/local/etc/php/7.1/conf.d/ext-opcache.ini,
/usr/local/etc/php/7.1/conf.d/ext-phalcon.ini,
/usr/local/etc/php/7.1/conf.d/ext-xdebug.ini,
/usr/local/etc/php/7.1/conf.d/php-memory-limits.ini
In you case it looks like you might have messed versions: your config file is located in /usr/local/etc/php/7.1/php.ini (version 7.1) but you are trying to put additional config files in /usr/local/etc/php/5.6/conf.d/ (version 5.6). Try to put them in /usr/local/etc/php/7.1/conf.d
You should specify extension dir path in your php.ini, I have the value
extension_dir = "/usr/local/lib/php/pecl/20160303"
This value is valid for php version 7.1, timestamp 20160303 specifies PHP API version for the extensions.
You can also check that PECL configuration for the extension dir has the same value as in php config using the command
pecl config-get ext_dir
After these steps you can check if extension is loaded with the command
php -m
It lists all the loaded php modules and extensions. If some extension is mentioned in config file but could not be loaded, you will get warning.
I'm using MAMP for Windows 10 , and I have a problem when I try to make a project with symfony. I install symfony with the installer and when I launch the command "php symfony new my_project_name", the installation doesn't work because of a time zone error.
To find the php.ini, I launch the php info on MAMP and it displays this
"Configuration File (php.ini) Path C:\WINDOWS
Loaded Configuration File C:\MAMP\conf\php5.6.3\php.ini "
and I checked on apache con (C:\MAMP\conf\apache\httpd.conf) for PHPIniDir : PHPIniDir "C:\MAMP\conf\php5.6.3\php.ini"
I modify the timezone parameter as follows
[Date]
; Defines the default timezone used by the date functions
date.timezone = Europe/Paris
and I launch the check but it seems that I didn't modify the right file. Also, there is a problem with my php.in; the following errors occur
Symfony2 Requirements Checker
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> PHP is using the following php.ini file:
WARNING: No configuration file (php.ini) used by PHP!
> Checking Symfony requirements:
.....E................W...WW.W.....
[ERROR]
Your system is not ready to run Symfony2 projects
Fix the following mandatory requirements
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* date.timezone setting must be set
> Set the "date.timezone" setting in php.ini* (like Europe/Paris).
Usually, the PHP CLI uses a different php.ini configuration than the Apache PHP. Could you check where is the right configuration file for command line? This topic can help you.
Then when you'll find it, just do the same as you did with the MAMP php.ini. It should work.
Find PHP.INI file for CLI like this:
hp -i |grep php.ini
and then modify date.timezone in it. Voila! It worked for me.
I use PHP on my Windows host system for composer. After a failed attempt to add parse/php-sdk to a project (since the SDK needs the PHP cURL module to be enabled), I updated the PHP settings. But it didn't solve the problem. Then I checked, whether the php.ini settings are correct:
C:\Users\me>php --info | grep "extension_dir"
extension_dir => ext => ext
C:\Users\me>php --info | grep "php.ini"
Configuration File (php.ini) Path => C:\Windows
Loaded Configuration File => C:\Program Files\php-5.6.8-Win32-VC11-x64\php.ini
Yes, they are. There is no C:\Windows\php.ini, but it doesn't matter -- the C:\Program Files\php-5.6.8-Win32-VC11-x64\php.ini is the file I updated and it's loaded.
Then I printed the modules list (php --modules) and noticed, that it has nothing in common with the extensions setting in the loaded php.ini. I also tried to change other settings (like memory_limit), but PHP seems to ignore my php.ini and load the configurations from somewhere else.
How to detect this magical "somewhere" (means: where PHP actually loads its settings from) and how to make it load the wished settings from the defined file?
The problem is caused by the fact, that php.ini is being edited by editor that wasn't run with elevated privileges. If the PHP folder sits inside "Program Files", you have to access the files within it with admin privileges.
I discovered the unbelievable fact, that the changes aren't saved into the php.ini despite the editor shows them correctly, even if closed/opened!
This can be simply verified by checking php.ini content - run more "C:\Program Files\... ...\php.ini" from the command line.
The solution is obvious - you have to run the editor with elevated privileges, or grant user permissions to the folder with php.ini and then edit it.
In phpInfo, MAMP's Loaded Configuration File is different to the one output when running php --ini:
Loaded Configuration File: /Library/Application Support/appsolute/MAMP PRO/conf/php.ini
Even though, directly above it states the same .ini file as output in the command line:
Configuration File (php.ini) Path: /Applications/MAMP/bin/php/php5.5.10/conf
Is there a way to get MAMP to load the configuration file listed in the row Configuration File (php.ini) Path which is also output with php --ini? Or do I just have to edit the one that MAMP is using?
which php outputs that it is using MAMP's php system:
/Applications/MAMP/bin/php/php5.5.10/bin/php
One php.ini for CLI (command line) and one for web server.
Keep them separated.
If you want to change the way php behave do it depending of the context.
For cli, change the php.ini you find doing php --ini -> Loaded Configuration File
For web server change the file found when doing a phpinfo() from your browser.
I have set up PHP 5.3.10 on a RHEL 4 server.
When I ran php -i | grep "Loaded" it returned
Loaded Configuration File => (none)
It's OK with that setup. PHP is working the way we needed it to. I just need to know, if no php.ini is being used, where does PHP get all its settings? Thanks.
Update: I realized this after I hit submit. Sorry, how do I move this to Stack Overflow? -_-
Update 2: Result of php --ini:
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
If there is no php configuration file loaded it just takes the default values. Please check the documentation to have the list of the default values :
http://php.net/manual/en/ini.core.php
It may depend on your server setup.
It could be (depending on PHP version) that the PHP configuration is controlled from within the Apache configuration files:
How to change configuration settings
You can use the phpinfo() function to view your PHP configuration settings (including the config file directory). Create a file called info.php (for example in the folder that is the "DocumentRoot"), and edit the file to contain the following code:
<? phpinfo(); ?>
So, if your domain is:
http://example.com
And your "DocumentRoot" is:
".../www" or ".../public_html"
Place the file in that folder and then using a browser, go to:
http://example.com/info.php
This should show you all the settings.
First of all you got to understand that command line PHP uses another php.ini. And Apache (or NGINX etc.) module uses another php.ini.
You may try use more reliable command: php --ini rather than php -i to make sure it's not loading any configs.
Usually it loads php.ini from /etc/php5
If the command is not showing you anything, so you may try to add that file (/etc/php5/cli/php.ini) manually and check.
In RedHat it may be directly on /etc/ directory.