Génère une entité Doctrine avec repository selon principes Elegant Objects
Génère une entité Doctrine complète avec son repository selon les principes Elegant Objects.
src/Entity/{EntityName}.phpsrc/Repository/{EntityName}Repository.phpsrc/Repository/{EntityName}RepositoryInterface.phpIMPORTANT : Exécute ce workflow étape par étape :
Question: "Quel est le nom de l'entité à créer ?"
Header: "Entité"
Question: "Quelles sont les propriétés de l'entité ? Format: name:type,email:string,age:int"
Header: "Propriétés"
ls src/Contracts/ avec Bash⚠️ Contracts manquants - Génération automatiquephp:make-contractscomposer.json avec Readautoload.psr-4App par défautsrc/Entity/{EntityName}.php avec Writenamespace {namespace}\Entity;
use Doctrine\ORM\Mapping as ORM;
use {namespace}\Repository\{EntityName}Repository;
#[ORM\Entity(repositoryClass: {EntityName}Repository::class)]
final class {EntityName}
{
#[ORM\Id]
#[ORM\Column(type: 'uuid', unique: true)]
private string $id;
// Propriétés générées depuis la liste
private function __construct() {}
public static function create({params}): self
{
$self = new self();
$self->id = Uuid::v7();
// Affectations des propriétés
return $self;
}
// Getters pour chaque propriété
}
src/Repository/{EntityName}RepositoryInterface.php avec Writenamespace {namespace}\Repository;
interface {EntityName}RepositoryInterface
{
public function find(string $id): ?{EntityName};
public function findAll(): array;
}
src/Repository/{EntityName}Repository.php avec Writenamespace {namespace}\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use {namespace}\Entity\{EntityName};
final class {EntityName}Repository extends ServiceEntityRepository implements {EntityName}RepositoryInterface
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, {EntityName}::class);
}
}
Affiche :
✅ Entité {EntityName} générée avec succès
Fichiers créés :
- src/Entity/{EntityName}.php
- src/Repository/{EntityName}Repository.php
- src/Repository/{EntityName}RepositoryInterface.php
Propriétés :
{liste des propriétés}
Prochaines étapes :
- Créer la migration : php bin/console make:migration
- Générer la factory : /php:make-factory {EntityName}
- Générer la collection : /php:make-collection {EntityName}
final, constructeur privé, factory statique create()final, extends ServiceEntityRepositorytoLog() inclut toutes les propriétés