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.
Related
Im using centos os and I have to make some changes in php.ini and set
phar.readonly = 0
in order to use phar.
I got a php.ini which is in /etc . By changes I restart web server but when I look into phpinfo() , nothing has changed.
when use phar in Terminal :
Fatal error : Uncaught exception 'UnexpectedValueException' with message 'creating archive "./build/myapp.phar" disabled by the php.ini setting phar.readonly'
Give some tips hints or something please, thanks
EDIT :
Loaded Configuration File: /etc/php.ini
There are multiple php.ini files.
Find out which one is being used by running php -i or calling phpinfo()
IF php.ini file is corrupted it will load defaults.
If you want to know where is php loading php.ini from OR you want to check for php.ini validity, run:
php -i
Run that command and if there is something wrong with the file it will tell you (check image). As well as file location
I'm using Debian 7 amd64 LAMP server on Oracle VM VirtualBox.
I'm trying to install Symfony and I'm having some lil problems
When I run command:
php my_project_name/app/check.php
It says:
[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).
I have already tried to edit php.ini file with following command:
sudo nano/etc/php5/apache2/php.ini
and there under [date] section; deleted ; and edited to: date.timezone = Europe/Helsinki
after that restarted.
in http://localhost/phpinfo.php there is correct Timezone.
Default timezone Europe/Helsinki,
(Local Value)
date.timezone Europe/Helsinki,
(Master Value)
Europe/Helsinki
Any tips? May there be another php.ini file Symfony uses?
You are executing the check script via command line, so the php.ini is different between the CLI and apache.
For find the correct php.ini for the cli lauch the following command:
php -i | grep 'php.ini'
And check the Loaded Configuration File line
Hope this help
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');
I'm trying to install a Symfony project on a new mac and I keep having this ErrorExeception:
[ErrorException] 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.
I have already verified my PHP version using phpinfo();.
The path for my php.ini is /Applications/MAMP/bin/php/php5.5.10/conf
I opened my php.ini and I changed the date.timezone to date.timezone = "Europe/Paris"
I restarted my MAMP many times and I keep having the same Error
I also noticed that I have a php.ini.temp in the same folder. I also changed the date.timezone in this file but it still doesn't work.
Does anyone have an idea about what is happening?
Thanks!
You should simple add to your Symfony controller :
phpinfo();
and you will know where your php.ini is located and you should make sure you changed value in this file.
You should also consider setting timezone in your script:
date_default_timezone_set('Europe/Paris');
because you (or someone else) may simple change it in future to other timezone
Symfony uses php command line (CLI) to make the install, so editing /etc/php5/apache2/php.ini will make no effect.
Try editing php-cli config. On debian:
vim /etc/php5/cli/php.ini
date.timezone = "Europe/Paris"
/etc/init.d/apache2 restart
I was installing Sylius and got into this similar issue.
I have changed the timezone in the php.ini which I got from phpinfo() script.
The configuration file location was: /etc/php/7.4/fpm/php.ini
Even after that, Sylius install reported the same issue. So, I followed the below steps.
Ran php -i | grep timezone:
Default timezone => Asia/Calcutta
date.timezone => no value => no value
Ran php -i | grep php.ini:
Configuration File (php.ini) Path => /etc/php/7.4/cli
Loaded Configuration File => /etc/php/7.4/cli/php.ini
After updating the value in the above CLI config file, everything went smooth.
$ su root
Enter root password
$ vim /etc/php.ini
Edit the timezone in this file
I'm want to start using phpDocumentor and the manual installation keeps throwing an error about me not having set detect_unicode = Off in my php.ini in Terminal.
When I add it to my php.ini it doesn't take and I get the same issue when running the install. Nobody seems to have this problem, and for the life of me I can't figure it out.
https://github.com/phpDocumentor/phpDocumentor2/blob/develop/README.md#installation
What am I missing? (I did restart the MAMP server after the php.ini edit)
Screenshot of the error in terminal...
If you have MAMP/MAMP Pro installed then the problem is that the PHP version available to your terminal will most probably be the system version located in:
/private/etc/
I had the same problem but in my case I didn't have a php.ini file in that directory so the best way to resolve it is to just create a symbolic link to the PHP version currently in use in your MAMP/MAMP Pro installation:
php.ini -> /Applications/MAMP/bin/php/php5.3.14/conf/php.ini
That solves the issue. Just change the php version php5.3.14 to whatever version of PHP you've selected to use in MAMP.
As #moderndegree mentions above, you can then optionally make this available to the terminal in the future by editing your path variable in your bash/zsh/etc:
export PATH="/Applications/MAMP/bin/php/php5.3.14/bin:$PATH"
You must not be editing the right php.ini if it still is enabled. Run php -i | grep ini to find all the ini files that are loaded.
The relevant lines are those two:
Loaded Configuration File => ...
Additional .ini files parsed => ...
The problem is that you are probably hitting a different php install.
Try the following:
which php
If you get anything other than, /Applications/MAMP/bin/..., you need update your environment to point to MAMP's installation.
To do this, you will need to add the following to .bash_profile (please update the path to match your setup):
export PATH="/Applications/MAMP/bin/php/php5.3.6/bin:$PATH"
Reload .bash_profile with the following command:
source .bash_profile
After you do this, you should be pointing to the correct php installation. Try which php again to confirm. Now run php -i | grep ini to confirm that the correct php.ini file is being loaded. As Seldaek stated, the relevant lines are:
Loaded Configuration File => ...
Additional .ini files parsed => ...
As I remember, MAMP uses configuration templates. So you should edit php.ini template. The actual php.ini will be regenerated from the template everytime you restart MAMP.
I faced the same problem for composer-php and i add this line manually into php.ini file. Like this:
sudo /private/etc/php.ini
then add this line "detect_unicode = Off"
detect_unicode = Off
then its work and i installed composer. You can see this
How to disable "detect_unicode" setting from php.ini? (trying to install Composer)
If you can't change your /usr/local/bin/php/php.ini file, remember to keep using '-d detect_unicode=Off' for all your php calls like so:
curl -s https://getcomposer.org/installer | php -d detect_unicode=Off
php -d detect_unicode=Off composer.phar install
If you are able to change your php.ini file, then add the following to the end of your php.ini:
detect_unicode = Off