Form Builder et migration
Bonjour,
Je cherche à réaliser un "Form Builder" avec Symfony 4.1 et Doctrine.
L'utilisateur peut créer son formulaire au moyen d'une interface graphique, nommer ses champs, les réorganiser.. Tout cela fonctionne bien.
Je génére un fichier d'Entity à base d'un template Twig et j'utilise des exec php pour la suite...
Code:
1 2 3 4 5 6 7
| $php = $this->renderView('doNotTouch/Entity.php.html', array(
'entity' => $entity,
));
file_put_contents(__DIR__ . '/../Entity/' . $entity['className'] .'.php', $php);
exec('php /home/vinceweb/sites/monsite/bin/console make:entity --regenerate App -q -n');
exec('php /home/vinceweb/sites/monsite/bin/console doctrine:migrations:diff', $out); |
Le premier "Exec" fonctionne bien. L'entité est bien écrite et les getters / setters sont générés aussi.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| <?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\TestRepository")
*/
class Test
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string")
*/
private $select;
/**
* @ORM\Column(type="string")
*/
private $text_field;
/**
* @ORM\Column(type="string")
*/
private $text_area;
/**
* @ORM\Column(type="string")
*/
private $radio_group;
public function getId(): ?int
{
return $this->id;
}
public function getSelect(): ?string
{
return $this->select;
}
public function setSelect(string $select): self
{
$this->select = $select;
return $this;
}
public function getTextField(): ?string
{
return $this->text_field;
}
public function setTextField(string $text_field): self
{
$this->text_field = $text_field;
return $this;
}
public function getTextArea(): ?string
{
return $this->text_area;
}
public function setTextArea(string $text_area): self
{
$this->text_area = $text_area;
return $this;
}
public function getRadioGroup(): ?string
{
return $this->radio_group;
}
public function setRadioGroup(string $radio_group): self
{
$this->radio_group = $radio_group;
return $this;
}
} |
MAIS le 2e ("doctrine:migrations:diff" ou "make:migration") ne renvoie rien depuis mon code... ?
Par contre, si j'appelle la commande directement dans la console, j'ai un résultat :
Code:
1 2
| php bin/console doctrine:migrations:diff
Generated new migration class to "/home/vinceweb/sites/monsite/src/Migrations/Version20180809150601.php" from schema differences. |
Auriez vous une idée de pourquoi la migration n'est pas générée depuis mon code php ? La j'avoue que je viens de bloquer dessus un bon moment.
Aucune erreur dans le log apache, aucune exception dans Symfony...