I downloaded Symfony2 et when I create a project /var/www/html# php ../symfony.phar new MyProject 2.8
At the end, I have this message :
Preparing project...
✕ Symfony 2.8.2 was successfully installed but your system doesn't meet its
technical requirements! Fix the following issues before executing
your Symfony application:
* date.timezone setting must be set
> Set the "date.timezone" setting in php.ini* (like Europe/Paris).
After fixing these issues, re-check Symfony requirements executing this command:
php Projet_miage/app/check.php
Then, you can:
* Change your current directory to /var/www/html/Projet_miage
* Configure your application in app/config/parameters.yml file.
* Run your application:
1. Execute the php app/console server:run command.
2. Browse to the http://localhost:8000 URL.
* Read the documentation at http://symfony.com/doc
But why ?
(I have xampp and I am on Ubuntu)
Because to make your application working properly, Symfony need some specific PHP configuration.
Find your php.ini by running:
php --ini
This will output something like :
Configuration File (php.ini) Path: /path/to/php
Loaded Configuration File: /path/to/php/php.ini
Then, open it:
nano /path/to/php/php.ini
Find the line date.timezone and change it to :
date.timezone = "Europe/Paris"
Of course, if "Europe/Paris" is not your timezone, you can replace by yours.
Please set the timezone in your php.ini
date.timezone = " Europe/Paris"
Restart xampp after that
Related
I'm trying to install Symfony on XAMPP and I keep getting numerous errors.
[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 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. in
/Applications/XAMPP/xamppfiles/htdocs/vendor/monolog/monolog/src/Monolog/Logger.php line 233
and then
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-
install-cmd event terminated with an exception
and finally
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
I've tried changing the date.timezone in my php.ini file and using the date_default_timezone_set() function in the command line before trying to install it and nothing seems to work.
I've been staring at it for a while so any help is appreciated
If you can't set it correctly in your php.ini for some reason then you can set it as the first thing in your AppKernel, like so..
class AppKernel extends Kernel
{
public function __construct($environment, $debug)
{
date_default_timezone_set('Europe/London');
parent::__construct($environment, $debug);
}
public function registerBundles()
{
$bundles = array(
....
);
}
....
}
Found a similar way to fix this issue while other didn't.
First check where the CLI php.ini is located:
php -i | grep "php.ini"
In my case I ended up with : Configuration File (php.ini) Path => /etc
Then cd .. all the way back and cd into /etc, do ls in my case php.ini didn't show up, only a php.ini.default
Now, copy the php.ini.default file named as php.ini:
sudo cp php.ini.default php.ini
In order to edit, change the permissions of the file:
sudo chmod ug+w php.ini
sudo chgrp staff php.ini
Open directory and edit the php.ini file:
open .
Tip: If you are not able to edit the php.ini due to some permissions issue then copy 'php.ini.default' and paste it on your desktop and rename it to 'php.ini' then open it and edit it following step 7. Then move (copy+paste) it in /etc folder. Issue will be resolved.
Search for [Date] and make sure the following line is in the correct format:
date.timezone = "Europe/Amsterdam"
It is very very common for WAMP/XAMPP and other stacks to have use of multiple php.ini files - one for cli and one for web.
Since you're expiriencing the error from CLI try the following:
php -i | grep "php.ini"
this will output location of php.ini used for cli. Edit the date.timezone there.
As for the web mode, create a file foo.php within your "web" directory of symfony containing only"
<?php phpinfo(); ?>
And, again, find the location of php.ini used and edit the date.timezone.
Edit your php.ini (not necessarily at /etc/php.ini - use php -i | grep ini to find your version) and add your timezone.
E.g. for America / New York it would be:
date.timezone = "America/New_York"
See http://php.net/manual/en/timezones.america.php
It's been mentioned but this is as simple as:
sudo cp /etc/php.ini.default /etc/php.ini
You can't set the timezone if it can't find the php.ini file!!!!
I've created a new Symfony project with
$ symfony new my_project
This is now in a folder called /Symfony/my_project
At this point I get this:
PHP Warning: date(): 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. in phar:///usr/local/bin/symfony/src/Symfony/Installer/NewCommand.php on line 262
✕ Symfony 2.7.3 was successfully installed but your system doesn't meet its
technical requirements! Fix the following issues before executing
your Symfony application:
* date.timezone setting must be set
> Set the "date.timezone" setting in php.ini* (like Europe/Paris).
Than says
Then, you can:
* Change your current directory to /Users/[username]/Dropbox/private/dbx/Symfony/my_project
* Configure your application in app/config/parameters.yml file.
* Run your application:
1. Execute the php app/console server:run command.
2. Browse to the http://localhost:8000 URL.
At this point I don't know where is the php.ini file in Yosemite. I've looked around and found an answer on this but the php.ini used is not the one I edited.
Which and where is the php.ini file to edit?
Try to modify the real php.ini, you can find it running php -i | grep "php.ini" on Terminal.
Remember that sometimes you'll find only a file called php.ini.default so you have to copy the file php.ini.default in a new php.ini file using sudo cp php.ini.default php.ini
Once you create the new php.ini file you have to change the permission in order to be able to modify the content:
sudo chmod ug+w php.ini
sudo chgrp staff php.ini
Now you can open the file php.ini and modify the date.timezone line.
NOTE: Remember to remove the comment if the line is commented.
If this doesn't work try to add the init function to your AppKernel.php file (code below), this really helped me.
<?php
class AppKernel extends Kernel
{
// Other methods and variables
// Append this init function below
public function init()
{
date_default_timezone_set( 'Europe/Paris' );
parent::init();
}
}
Since this is Terminal-based run and not browser based you can easily find that out. From your Terminal, run this:
php -i | grep "php.ini"
This will output the location of php.ini used. Then edit the file via any text editor (graphic or otherwise) and set the approprite time zone.
Hope this helps.
I have a problem with the setup of Symfony 2 localy on xampp.
The installation was no problem but when I execute the check.php it says:
Your system is not ready to run Symfony2 projects
* date.timezone setting must be set
> Set the "date.timezone" setting in php.ini* (like Europe/Paris).
But the date.timezone in the php.ini is already set correctly.
you can add this to your AppKernel.php
public function init()
{
// get rid of Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone
date_default_timezone_set( 'Europe/Paris' );
parent::init();
}
for some reason you have to change the date.timezone in
php.ini
in the
cli folder
got the hint when I tried to start a new project in Symfony3.
even if phpinfo() shows that the
php.ini file is in apache2 folder
If you are facing following problem :
Your system is not ready to run Symfony2 projects
* date.timezone setting must be set
> Set the "date.timezone" setting in php.ini* (like Europe/Paris)
Simply replace the |localizeddate('long','long') with |date('r') in app/Resources/views/base.html.twig file.
What worked for me is to add the -k option when restarting Apache
I am trying to install Symfony with my Apache (Ubuntu) but I get this error:
Set the "date.timezone" setting in php.ini* (like Europe/Paris)
Using phpinfo() in my browser it says that the configuration file is in /etc/php5/apache2/php.ini So I modified it wtih
date.timezone = "Europe/Paris"
I also modified the file /etc/php5/cli/php.ini
I also run php app/console cache:clear as it was suggested in this question Fixing requirements in Symfony2 but with no results. I restarted the server every time.
What else can I try?
Thanks!
Try removing double quotes
date.timezone = Europe/Paris
Please see David Jacquel correct solution below !
I leave this answer for historical purposes...
In sf1, I ran through this and got it fixed with a
date_default_timezone_set('Europe/Madrid');
in the bootstrap (that was ProjectConfiguration.class.php).
In sf2 you may modify the web/app.php file to insert the same piece of code. It is a bit hackyish, but will get you up and running.
I'm trying to install Symfony on XAMPP and I keep getting numerous errors.
[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 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. in
/Applications/XAMPP/xamppfiles/htdocs/vendor/monolog/monolog/src/Monolog/Logger.php line 233
and then
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-
install-cmd event terminated with an exception
and finally
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
I've tried changing the date.timezone in my php.ini file and using the date_default_timezone_set() function in the command line before trying to install it and nothing seems to work.
I've been staring at it for a while so any help is appreciated
If you can't set it correctly in your php.ini for some reason then you can set it as the first thing in your AppKernel, like so..
class AppKernel extends Kernel
{
public function __construct($environment, $debug)
{
date_default_timezone_set('Europe/London');
parent::__construct($environment, $debug);
}
public function registerBundles()
{
$bundles = array(
....
);
}
....
}
Found a similar way to fix this issue while other didn't.
First check where the CLI php.ini is located:
php -i | grep "php.ini"
In my case I ended up with : Configuration File (php.ini) Path => /etc
Then cd .. all the way back and cd into /etc, do ls in my case php.ini didn't show up, only a php.ini.default
Now, copy the php.ini.default file named as php.ini:
sudo cp php.ini.default php.ini
In order to edit, change the permissions of the file:
sudo chmod ug+w php.ini
sudo chgrp staff php.ini
Open directory and edit the php.ini file:
open .
Tip: If you are not able to edit the php.ini due to some permissions issue then copy 'php.ini.default' and paste it on your desktop and rename it to 'php.ini' then open it and edit it following step 7. Then move (copy+paste) it in /etc folder. Issue will be resolved.
Search for [Date] and make sure the following line is in the correct format:
date.timezone = "Europe/Amsterdam"
It is very very common for WAMP/XAMPP and other stacks to have use of multiple php.ini files - one for cli and one for web.
Since you're expiriencing the error from CLI try the following:
php -i | grep "php.ini"
this will output location of php.ini used for cli. Edit the date.timezone there.
As for the web mode, create a file foo.php within your "web" directory of symfony containing only"
<?php phpinfo(); ?>
And, again, find the location of php.ini used and edit the date.timezone.
Edit your php.ini (not necessarily at /etc/php.ini - use php -i | grep ini to find your version) and add your timezone.
E.g. for America / New York it would be:
date.timezone = "America/New_York"
See http://php.net/manual/en/timezones.america.php
It's been mentioned but this is as simple as:
sudo cp /etc/php.ini.default /etc/php.ini
You can't set the timezone if it can't find the php.ini file!!!!