Warning: date_default_timezone_get(): It is not safe to rely on the system timezone settings when creating a Doctrine Entity from the command line in Symfony 2

Practice




When creating a Doctrine Entity in Symfony 2

using the command line

c:OpenServerdomainsmysite>....modulesphpPHP-5.4.13php.exe appconsole
doctrine:generate:entity


the error appears: Warning: date_default_timezone_get(): It is not safe to rely on the system t imezone settings.

Warning: date_default_timezone_get(): It is not safe to rely on the system's t
imezone settings. You are *required* to use the date.timezone setting or the dat
e_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 identif
ier. We selected the timezone 'UTC' for now, but please set date.timezone to sel
ect your timezone. in C:Serverdomainsmysitevendormonologmonologsrc
MonologLogger.php line 111

C:OpenServerdomainsmysitevendormonologmonologsrc
MonologLogger.php line 112




either change the php.ini config, set the time zone
date.timezone='Europe/Moscow'


or add to the Logger.php file
date_default_timezone_set('Europe/Moscow');

thanks, seems to have helped

can you describe the sequence of steps for creating an entity in Doctrine

run from the command line

c:OpenServerdomainsmysite>....modulesphpPHP-5.4.13php.exe appconsole
doctrine:generate:entity



Welcome to the Doctrine2 entity generator

This command helps you generate Doctrine2 entities.

First, you need to give the entity name you want to generate.
You must use the shortcut notation like AcmeBlogBundle:Post.


Then Doctrine will ask you to enter field names and types - private properties and methods for setting or getting the values will be automatically created for them

The Entity shortcut name:
The entity name must contain a : ("" given, expecting something like AcmeBlogBu
ndle:Blog/Post)


The Entity shortcut name:AcmeUserBundle:MYEntityName


Determine the format to use for the mapping information.

Configuration format (yml, xml, php, or annotation) [annotation]:

Instead of starting with a blank entity, you can add some fields now.
Note that the primary key will be added automatically (named id).

Available types: array, simple_array, json_array, object,
boolean, integer, smallint, bigint, string, text, datetime, datetimetz,
timestamp, date, time, decimal, float, blob, guid.


New field name (press to stop adding fields): id
Field "id" is already defined.
New field name (press to stop adding fields): field2
Field type [string]: text

New field name (press to stop adding fields): field3
Field type [string]: text

New field name (press to stop adding fields):

Do you want to generate an empty repository class [no]? yes


Summary before generation


You are going to generate a "AcmeUserBundle:MYEntityName" Doctrine2 entity
using the "annotation" format.

Do you confirm generation [yes]? yes


Entity generation


Generating the entity code: OK


You can now start using the generated code!



then go into the generated file, check the namespaces/use statements
fill in which database table the entity maps to
- to do this, write the table name....

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Running server side scripts using PHP as an example (LAMP)"

Terms: Running server side scripts using PHP as an example (LAMP)