Last Updated: February 25, 2016
·
1.275K
· gxela

Symfony 2.0 to 2.3 update, entity length and nullable properties

length property in Symfony 2.3 Entities is of type integer

run this:

php app/console cache:clear --env prod

get this error:

[Doctrine\Common\Annotations\AnnotationException]                                                                                                 

[Type Error] Attribute "length" of ... expects a(n) integer, but got string.

change:

...(name="type", type="string", length="10")

to:

...(name="type", type="string", length=10)

notice the lack of quotes around the length property value

Change all instances of this string-part in your code, length="X" to length=X

do the same thing for nullable property too, change:

nullable="true"

to:

nullable=true

to find all instances that need to be replaced and replace them manually, type:

egrep -Rn 'length="|nullable="' /path/to/symfony

don't worry about changing strings in vendor/, just make the changes in your application and the errors will go away.