Aay*_*ush 2 php console symfony
我昨天尝试了最近发布的发电机,但我遇到了一个问题.我能够正确地创建数据库和实体.但是当我尝试创建架构时,它开始显示错误,如:
php app/console doctrine:schema:create
[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] The annotation "@Table" in class Acme\BlogBundle\Entity\Post was never imported.
doctrine:schema:create [--dump-sql] [--em[="..."]]
Run Code Online (Sandbox Code Playgroud)
我终于找到了问题,就是生成的实体有注释,如:
/**
* Acme\BlogBundle\Entity\Post
*
* @Table()
* @Entity
*/
Run Code Online (Sandbox Code Playgroud)
代替:
/**
* Acme\BlogBundle\Entity\Post
*
* @ORM\Table(name="post")
* @ORM\Entity
*/
Run Code Online (Sandbox Code Playgroud)
我必须在@Table注释中添加表名,并在所有注释中手动添加ORM \.
现在错误已经改变:
php app/console doctrine:schema:create
ATTENTION: This operation should not be executed in a production environment.
Creating database schema...
[Exception] DateTime::__construct(): 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 'Asia/Calcutta' for 'IST/5.0/no DST' instead.
doctrine:schema:create [--dump-sql] [--em[="..."]]
Run Code Online (Sandbox Code Playgroud)
如何修复时区错误.
我看到了Symfony Interactive Generators视频,该实体默认生成@ORM \.只有表名用于手动添加.为什么我的发行版使用错误的注释生成它.
这是您的配置设置时区的PHP问题
date_default_timezone_set('America/Los_Angeles');
Run Code Online (Sandbox Code Playgroud)
控制台通常有一个单独的php.ini文件.
运行php -i | grep "Configuration File"此命令将告诉您控制台的ini文件位于何处.在该文件中添加或编辑时区:date.timezone = my/timezone.
或者你可以添加date_default_timezone_set()到app/AppKernel.php的顶部.