Gerando getters and setters de uma entity do Doctrine
De Basef
Supondo que temos a entity Product, já criada, em src/AppBundle/Entity/Product.php, com o conteúdo:
<?php namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\Table(name="product") */ class Product { /** * @ORM\Column(type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @ORM\Column(type="string", length=100) */ private $name; /** * @ORM\Column(type="decimal", scale=2) */ private $price; /** * @ORM\Column(type="text") */ private $description; }
Para gerar os getters e setters dos atributos:
php bin/console doctrine:generate:entities AppBundle/Entity/Product
Note que é muito importante o uso de:
use Doctrine\ORM\Mapping as ORM;