AngelGris
AngelGris

Reputation: 813

Symfony2 doctrine:generate:entity and Fatal Parse Error

I'm getting started with Symfony2 and reading the book I got ot the doctrine entity generator code. Used the example in the book:

php app/console doctrine:generate:entity --no-interaction --entity="AppBundle:Category" --fields="name=string(255)"

and the new entity was created as expected, but I noticed that it generated some PHP code I'm not familiar with:

private $name=string(255);

and

public function setName=string(255)($name=string(255))

I've never seen before the string(255) when declaring a variable nor a function, and when I run

php app/console doctrine:generate:entities AppBundle

It throws an Fatal Parse Error on those lines. Removing the string(255) thing solves it. So, is it fine that Doctrine adds that code and my PHP interpreter's configuration is wrong? Doctrine shouldn't be adding that code or should I remove it after generating the entities? and finally, removing that code won't have consequences in the future?

Thanks,

Upvotes: 0

Views: 126

Answers (1)

vstm
vstm

Reputation: 12537

If you look at the documentation for doctrine:generate:entity, you'll see that the format for declaring the fields looks actually like this:

... --fields="name:string(255)"

So you have to use a : (colon) to separate the field name of the type instead of an equal sign.

Upvotes: 2

Related Questions