Bonjour
J'essaie d'utiliser Doctrine 2 sans Framework.
J'ai suivi le tuto suivant :
http://www.wewereweb.be/installer-et...rk/2014/02/27/
il s'agit de générer des entités à partir d'une base de données existante.
Donc mon arborescence est la suivante :
Pièce jointe 150788
Mon fichier bootstrap.php :
et mon fichier cli-config.php :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 // bootstrap.php require_once "vendor/autoload.php"; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Tools\Setup; //$paths = array("model"); $isDevMode = true; // the connection configuration $dbParams = array( 'hostname' => 'localhost', 'driver' => 'pdo_mysql', 'user' => 'root', 'password' => 'root', 'dbname' => 'Sports' ); //$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode); $config = Setup::createAnnotationMetadataConfiguration(array("/home/elodie/public_html/projetTestDoctrine/src/Entities"), $isDevMode); $entityManager = EntityManager::create($dbParams, $config);
quand je tape la commandeCode:
1
2
3
4
5
6
7
8
9
10
11 use Doctrine\ORM\Tools\Console\ConsoleRunner; // replace with file to your own project bootstrap require_once 'bootstrap.php'; $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array( 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($entityManager) )); return $helperSet;
,Code:php vendor/bin/doctrine orm:convert-mapping --force annotation --from-database ./src/Entities
j'ai bien des classes générées dans le dossier Entities.
Exemple :
Association.php
et quand je tape la commande pour générer les accesseurs :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 <?php use Doctrine\ORM\Mapping as ORM; /** * Association * * @ORM\Table(name="association", indexes={@ORM\Index(name="nom", columns={"Nom"}), @ORM\Index(name="associationIdFederation", columns={"IdFederation"})}) * @ORM\Entity */ class Association { /** * @var integer * * @ORM\Column(name="Id", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id; /** * @var string * * @ORM\Column(name="Nom", type="string", length=200, nullable=true) */ private $nom; /** * @var \Federation * * @ORM\ManyToOne(targetEntity="Federation") * @ORM\JoinColumns({ * @ORM\JoinColumn(name="IdFederation", referencedColumnName="Id") * }) */ private $idfederation; /** * @var \Doctrine\Common\Collections\Collection * * @ORM\ManyToMany(targetEntity="Membre", inversedBy="idassociation") * @ORM\JoinTable(name="associationmembre", * joinColumns={ * @ORM\JoinColumn(name="IdAssociation", referencedColumnName="Id") * }, * inverseJoinColumns={ * @ORM\JoinColumn(name="IdMembre", referencedColumnName="Id") * } * ) */ private $idmembre; /** * Constructor */ public function __construct() { $this->idmembre = new \Doctrine\Common\Collections\ArrayCollection(); } }
j'ai l'erreur suivante :Code:php vendor/bin/doctrine orm:generate-entities ./src/Entities --generate-annotations=true
ça fait deux jours que je galère.Citation:
No Metadata Classes to process.
j'ai regardé le message dans le forum où l'utilisateur a trouvé une solution à son problème en utilisant les sources de GitHub.
pour ma part, même en reprenant le code, cela ne marche pas.
il me manque un petit truc je suis sûre mais je ne vois pas quoi.
voilà, merci d'avance et bonne journée
Edit : j'ai finalement trouvé le problème
il faut indiquer à Doctrine un driver à utiliser pour générer les entités
j'ai finalement transformé mes fichiers en xml pour plus de clarté et ne pas confondre metadata et entité.
j'ai ensuite mis dans bootstrap.php,et la génération a fonctionné.Code:
1
2
3 $config->setMetadataDriverImpl( new Doctrine\ORM\Mapping\Driver\XmlDriver( 'src/metadata' ) );