I am trying to add a new bundle using the console with the follow code...
php app/console generate:bundle
How ever it is giving me the following error...
[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 /Users/Phil/Sites/SoccerTips24
/vendor/monolog/monolog/src/Monolog/Logger.php line 233
generate:bundle [--namespace="..."] [--dir="..."] [--bundle-name="..."] [--format="..."] [--structure]
I understand the first one is something to do with the time settings but then bundles wont add to my src folder...
Any ideas how to fix?
Set timezone in your php.ini
php -i |grep php.ini
uncomment timezone record, and set you timezone:
date.timezone = "Europe/Paris"
Once you go to your php.ini and set your timezone it should work.
Related
Documentation for MariaDB says clearly how to set up server defaults like charset and collation. So I opened my Mariadb console and run:
SET character_set_server = 'utf8mb4';
SET collation_server = 'utf8mb4_slovak_ci';
Consoles wrote OK.
Then I restart the server, but as I tried to create new database there are still the same latin2 charset and swedish collation.
I do it automatically via Symfony cosole command
php bin/console doctrine:database:create
What is wrong with that? I did it like documentation says.
SET character_set_server changes the character set for the current connection.
SET global character_set_server changes the character set globally for each new connection.
However if you restart your server the default character sets for server will be read from the configuration file. If the configuration file doesn't specify character set, then defaults will be used. So for making your settings permanent, you have to change the character sets in your configuration file (https://mariadb.com/kb/en/configuring-mariadb-with-option-files/)
First, run the SHOW VARIABLES like "%collation%"; to show you the current configs.
To change collation_server setting, you have to use the keyword GLOBAL and therefore your statement will be SET GLOBAL collation_server = 'utf8mb4_slovak_ci';
I have researched all the answers I can find for this and have had no luck getting it to work.
I am getting the following error when I try to run symfony.
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 /symfony_project/app/cache/dev/classes.php
line 5229
I have checked the following :
php --ini
Configuration File (php.ini) Path: /etc Loaded Configuration File:
/etc/php.ini
I have changed the ini file to date.timezone = "Europe/Dublin"
restarted apache
Cleared the cli cache
cleared the browser cache
Ran phpinfo and confirmed the
loaded config file is etc/php.ini
Additional .ini files parsed (none)
date.timezone = "Europe/Dublin"
I also ran echo date_default_timezone_get() in the browser and I get Europe/Dublin
I am running PHP v 5.4.24 (for what its worth)
I ran echo date_default_timezone_get() inside
which returns UTC ... so it looks like symfony is not reading the php.ini file properly.
Not sure what else I can do.
find your php.ini file path
php -i | grep php.ini
edit php.ini date_timezone set it is your timezone
time_zone = "Asia/Shanghai"
restart your nginx and php-fpm
When running phpunit --coverage-html I get the well-known warning about timezones.
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.
Everything works as expected, but it becomes really annoying.
Of course, I could solve this by changing my php.ini, but I'd prefer to avoid it, if possible, in order to keep some server-agnosticism. In addition, I don't want to prevent this warning to appear if triggered by my testable code.
Is there a way to define the default timezone only for internal PHPUnit operations?
I set the TimeZone in the bootstrap.php file.
<?php
// PHP and Web server settings
error_reporting(E_ALL | E_STRICT);
date_default_timezone_set("America/Toronto"); // Set the default timezone
$_SERVER['SERVER_NAME'] = 'http://myserver'; // Set Web Server name
// Process the Include Path to allow the additional application to be set.
$IncludePaths = explode( PATH_SEPARATOR, get_include_path() );
$NewIncludePaths = array_merge( $IncludePaths, array(dirname(__FILE__) ));
set_include_path( implode( PATH_SEPARATOR, array_unique($NewIncludePaths))); // Update Include Path
//define('PHPUNIT_RUNNING', 1); // Indicate to the code that Automated Testing is running.
?>
I am trying to create my own authentication provider like in http://symfony.com/doc/current/cookbook/security/custom_authentication_provider.html.
But, it keeps saying:
ErrorException: Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in /../../vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php line 56
Symfony2 sessions will not work properly with "session auto start" enabled. So make sure that's disabled.
Make sure your php configuration php.ini has this configured: session.auto_start = 0.
Or you can add php_flag session.auto_start 0 to your .htaccess file if you can not edit the php.ini file.
Additionally, there's one more possibility to get this error, as I found out after a long time of struggling:
For whatever reason, this crucial part was commented out in my config_test.yml, giving me exactly the same error:
framework:
session:
storage_id: session.storage.mock_file
The storage_id setting must be in place to avoid the problem.
Im using Gedmo bundle to save automatically the time in two rows "created_at" and "updated_at",all works fine but it save the data with a wrong time,for example when I save something in 2:00 pm I find it put 4:00pm in database...its very weird...
Locate the php.ini file on your machine
in my machine file located at "/etc/php5/apache2/php.ini"
Find the line with ;date.timezone = under the [Date] section, and set it to your timezone based on PHP's list of timezones
I chose Asia/Kolkata because i lived there. Also, make sure to remove the semicolon at the beginning of the line!
Don't forget to restart apache - sudo service apache2 restart
Change timezone using below php function.
date_default_timezone_set('YourTimeZone');
For more detail refer : http://php.net/manual/en/function.date-default-timezone-set.php