Symfony2 doctrine:generate:entities throw Syntax Error?

隐身守侯 提交于 2020-01-23 06:04:10

问题


when i am using the symfony2 shell and trying to run

doctrine:generate:entities [MyBundle] --path='src' 

or

doctrine:generate:entities [MyBundle] 

i got this error

[Syntax Error] Expected Doctrine\Common\Annotations\DocLexer::T_CLOSE_CURLY_BRACES, got '@' at position 255 in property

so please any solutions ??

thanks in advance


回答1:


I've encountered this error also. It's just a simple typo in one of your Entity annotations. A quick check of your entities will reveal something like this:

/**
 * @ORM\Id
 * @ORM\Column(type="integer"              // note the missing close parentheses
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;

Taking into account the line number, it's probably somewhere in one of your entity association mappings.




回答2:


Just as cantera says, check the curly braces.

Here are some of symfony annotation errors:

The comma

  • Sample Code: @ORM\Column(name="column_name" type="string" length=20 nullable=false)
  • Error Message: [Syntax Error] Expected Doctrine\Common\Annotations\DocLexer::T_CLOSE_PARENTHESIS, got 'type' at position 62 in property ...

Using the wrong type

  • Sample Code: @ORM\Column(name="column_name", type="string", length="20", nullable=false)
  • Error Message: [Type Error] Attribute "length" of @ORM\Column declared on property ...


来源:https://stackoverflow.com/questions/9273299/symfony2-doctrinegenerateentities-throw-syntax-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!