Symfony2 teaching: generate: do entities throw a syntax error?

when I use symfony2 shell and try 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 

please make any decisions.

early

+4
source share
2 answers

I also ran into this error. It's just a typo in one of your Entity annotations. A quick scan of your objects will open something like this:

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

Given the line number, it is probably located somewhere in one of the associations of entity associations.

+22
source

As Kanter says, check the curly braces.

Here are some of the symfony annotation errors:

Comma

  • Code example: @ORM \ Column (name = "column_name" type = "string" length = 20 nullable = false)
  • Error message: [Syntax error] Expected Doctrine \ General \ Annotations \ DocLexer :: T_CLOSE_PARENTHESIS, received a "type" at position 62 in the property ...

Using the wrong type

  • Code example: @ORM \ Column (name = "column_name", type = "string", length = "20", nullable = false)
  • Error message: [Type of error] Attribute "length" @ORM \ Column declared in property ...
+6
source

Source: https://habr.com/ru/post/1396350/


All Articles