I\'ve been playing around with Symfony on my web server and I\'ve been creating entity with doctrine for my database. I wanted to add a column to one of these entity... I wa
here you have to follow two steps to make changes in your entity Step1: Open Your Entity File..For EX: "Acme\MyBundle\Entity\Book"
Current Entity is having few fields like:id,name,title etc. Now if you want to add new field of "image" and to make change constraint of "title" field then add field of "image" with getter and setter
/**
* @var string
*
* @ORM\Column(name="image", type="string", length=500)
*/
private $image;
And add getter and setter
/**
* Set image
*
* @param string $image
*
* @return Book
*/
public function setImage($image)
{
$this->image = $image;
return $this;
}
/**
* Get image
*
* @return string
*/
public function getimage()
{
return $this->image;
}
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=500)
*/
private $title;
Ok...You have made changes according to your need,And You are one step away.
Step 2: Fire this command in project directory
php bin/console doctrine:schema:update --force
Now,check your table in database ,It's Done!!