Tu as les fichiers .php~ dans MyApp/emploiBundle/Entity aprés avoir tapé la commande :
??Code:
1
2 php app/console doctrine:generate:entities MyAppemploiBundle
Version imprimable
Tu as les fichiers .php~ dans MyApp/emploiBundle/Entity aprés avoir tapé la commande :
??Code:
1
2 php app/console doctrine:generate:entities MyAppemploiBundle
j 'ai tapé ces deux commande
et j 'ai eu les entités sous le dossier entityCode:
1
2
3
4 php app/console doctrine:mapping:import "MyAppemploiBundle" yml php app/console doctrine:generate:entities "MyAppemploiBundle"
je sais pas pourquoi ca marche pas cette commande php app/console generate:doctrine:crud et elle m 'affiche que le clé primaire n 'existe pas mais il existe :cry:
oui j 'ai prend la base de directeur de société je pas le droit de le modifier
est ce que il y 'a une autre solution ?
Non efface tous les fichiers dans : MyApp/emploiBundle/Entity et refais les 2 commandes il te faut les annotations :
Tu verra ca va marcher ;)Code:
1
2
3
4 php app/console doctrine:mapping:import MyAppemploiBundle annotation php app/console doctrine:generate:entities MyAppemploiBundle
même problème :cry: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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214 C:\wamp\www\portail>php app/console doctrine:mapping:import MyAppemploiBundle an notation Importing mapping information from "default" entity manager > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobCandAssociati ons.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobCandCompetenc es.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobCandCoordonne es.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobCandCv.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobCandDernierIn scription.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobCandEmploiRec herche.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobCandExperienc eTravail.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobCandInformati onsComplementaires.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobCandInformati onsGenerales.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobCandLangues.p hp > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobCandLettrePre sentation.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobCandProfilSys teme.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobCandReference .php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobCandRegionVis ee.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobCandScolarite .php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobLstEtatCivil. php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobLstLangue.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobLstNiveauCarr iere.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobLstNiveauComp etence.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobLstNiveauEtud e.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobLstPays.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobLstRegionVise e.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvJobLstServiceMil itaire.php > writing C:\wamp\www\portail\src\MyApp\emploiBundle/Entity/PvTousAuthentifica tion.php C:\wamp\www\portail>php app/console doctrine:generate:entities MyAppemploiBundle Generating entities for bundle "MyAppemploiBundle" > backing up PvJobCandAssociations.php to PvJobCandAssociations.php~ > generating MyApp\emploiBundle\Entity\PvJobCandAssociations > backing up PvJobCandCompetences.php to PvJobCandCompetences.php~ > generating MyApp\emploiBundle\Entity\PvJobCandCompetences > backing up PvJobCandCoordonnees.php to PvJobCandCoordonnees.php~ > generating MyApp\emploiBundle\Entity\PvJobCandCoordonnees > backing up PvJobCandCv.php to PvJobCandCv.php~ > generating MyApp\emploiBundle\Entity\PvJobCandCv > backing up PvJobCandDernierInscription.php to PvJobCandDernierInscription.ph p~ > generating MyApp\emploiBundle\Entity\PvJobCandDernierInscription > backing up PvJobCandEmploiRecherche.php to PvJobCandEmploiRecherche.php~ > generating MyApp\emploiBundle\Entity\PvJobCandEmploiRecherche > backing up PvJobCandExperienceTravail.php to PvJobCandExperienceTravail.php~ > generating MyApp\emploiBundle\Entity\PvJobCandExperienceTravail > backing up PvJobCandInformationsComplementaires.php to PvJobCandInformations Complementaires.php~ > generating MyApp\emploiBundle\Entity\PvJobCandInformationsComplementaires > backing up PvJobCandInformationsGenerales.php to PvJobCandInformationsGenera les.php~ > generating MyApp\emploiBundle\Entity\PvJobCandInformationsGenerales > backing up PvJobCandLangues.php to PvJobCandLangues.php~ > generating MyApp\emploiBundle\Entity\PvJobCandLangues > backing up PvJobCandLettrePresentation.php to PvJobCandLettrePresentation.ph p~ > generating MyApp\emploiBundle\Entity\PvJobCandLettrePresentation > backing up PvJobCandProfilSysteme.php to PvJobCandProfilSysteme.php~ > generating MyApp\emploiBundle\Entity\PvJobCandProfilSysteme > backing up PvJobCandReference.php to PvJobCandReference.php~ > generating MyApp\emploiBundle\Entity\PvJobCandReference > backing up PvJobCandRegionVisee.php to PvJobCandRegionVisee.php~ > generating MyApp\emploiBundle\Entity\PvJobCandRegionVisee > backing up PvJobCandScolarite.php to PvJobCandScolarite.php~ > generating MyApp\emploiBundle\Entity\PvJobCandScolarite > backing up PvJobLstEtatCivil.php to PvJobLstEtatCivil.php~ > generating MyApp\emploiBundle\Entity\PvJobLstEtatCivil > backing up PvJobLstLangue.php to PvJobLstLangue.php~ > generating MyApp\emploiBundle\Entity\PvJobLstLangue > backing up PvJobLstNiveauCarriere.php to PvJobLstNiveauCarriere.php~ > generating MyApp\emploiBundle\Entity\PvJobLstNiveauCarriere > backing up PvJobLstNiveauCompetence.php to PvJobLstNiveauCompetence.php~ > generating MyApp\emploiBundle\Entity\PvJobLstNiveauCompetence > backing up PvJobLstNiveauEtude.php to PvJobLstNiveauEtude.php~ > generating MyApp\emploiBundle\Entity\PvJobLstNiveauEtude > backing up PvJobLstPays.php to PvJobLstPays.php~ > generating MyApp\emploiBundle\Entity\PvJobLstPays > backing up PvJobLstRegionVisee.php to PvJobLstRegionVisee.php~ > generating MyApp\emploiBundle\Entity\PvJobLstRegionVisee > backing up PvJobLstServiceMilitaire.php to PvJobLstServiceMilitaire.php~ > generating MyApp\emploiBundle\Entity\PvJobLstServiceMilitaire > backing up PvTousAuthentification.php to PvTousAuthentification.php~ > generating MyApp\emploiBundle\Entity\PvTousAuthentification C:\wamp\www\portail>php app/console generate:doctrine:crud Welcome to the Doctrine2 CRUD generator This command helps you generate CRUD controllers and templates. First, you need to give the entity for which you want to generate a CRUD. You can give an entity that does not exist yet and the wizard will help you defining it. You must use the shortcut notation like AcmeBlogBundle:Post. The Entity shortcut name: MyAppemploiBundle:PvJobCandAssociations 'stty' n'est pas reconnu en tant que commande interne ou externe, un programme exécutable ou un fichier de commandes. [Doctrine\ORM\Mapping\MappingException] No identifier/primary key specified for Entity 'MyApp\emploiBundle\Entity\PvJo bCandProfilSysteme'. Every Entity must have an identifier/primary key. doctrine:generate:crud [--entity="..."] [--route-prefix="..."] [--with-write] [- -format="..."] C:\wamp\www\portail>php app/console generate:doctrine:crud Welcome to the Doctrine2 CRUD generator This command helps you generate CRUD controllers and templates. First, you need to give the entity for which you want to generate a CRUD. You can give an entity that does not exist yet and the wizard will help you defining it. You must use the shortcut notation like AcmeBlogBundle:Post. The Entity shortcut name: MyAppemploiBundle:PvJobCandAssociations 'stty' n'est pas reconnu en tant que commande interne ou externe, un programme exécutable ou un fichier de commandes. [Doctrine\ORM\Mapping\MappingException] No identifier/primary key specified for Entity 'MyApp\emploiBundle\Entity\PvJo bCandProfilSysteme'. Every Entity must have an identifier/primary key. doctrine:generate:crud [--entity="..."] [--route-prefix="..."] [--with-write] [- -format="..."] C:\wamp\www\portail>php app/console generate:doctrine:crud Welcome to the Doctrine2 CRUD generator This command helps you generate CRUD controllers and templates. First, you need to give the entity for which you want to generate a CRUD. You can give an entity that does not exist yet and the wizard will help you defining it. You must use the shortcut notation like AcmeBlogBundle:Post. The Entity shortcut name: MyAppemploiBundle:emploi/PvJobCandCompetences 'stty' n'est pas reconnu en tant que commande interne ou externe, un programme exécutable ou un fichier de commandes. [Doctrine\ORM\Mapping\MappingException] No identifier/primary key specified for Entity 'MyApp\emploiBundle\Entity\PvJo bCandProfilSysteme'. Every Entity must have an identifier/primary key. doctrine:generate:crud [--entity="..."] [--route-prefix="..."] [--with-write] [- -format="..."] C:\wamp\www\portail>
donnes nous le contenu de ton entité : Entity/PvJobCandAssociations.php jusqu’à la ligne :
Code:
1
2 private $id;
voir mon entité
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197 <?php namespace MyApp\emploiBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * MyApp\emploiBundle\Entity\PvJobCandAssociations * * @ORM\Table(name="pv__job_cand_associations") * @ORM\Entity */ class PvJobCandAssociations { /** * @var integer $codeAsc * * @ORM\Column(name="code_asc", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $codeAsc; /** * @var integer $codeCv * * @ORM\Column(name="code_cv", type="integer", nullable=false) */ private $codeCv; /** * @var string $nomOrganismeAsc * * @ORM\Column(name="nom_organisme_asc", type="string", length=254, nullable=true) */ private $nomOrganismeAsc; /** * @var string $nomClubAsc * * @ORM\Column(name="nom_club_asc", type="string", length=254, nullable=true) */ private $nomClubAsc; /** * @var string $roleCandOrgAsc * * @ORM\Column(name="role_cand_org_asc", type="string", length=254, nullable=true) */ private $roleCandOrgAsc; /** * @var datetime $debutAdhesionAsc * * @ORM\Column(name="debut_adhesion_asc", type="datetime", nullable=true) */ private $debutAdhesionAsc; /** * @var datetime $finAdhesionAsc * * @ORM\Column(name="fin_adhesion_asc", type="datetime", nullable=true) */ private $finAdhesionAsc; /** * Get codeAsc * * @return integer */ public function getCodeAsc() { return $this->codeAsc; } /** * Set nomOrganismeAsc * * @param string $nomOrganismeAsc */ public function setNomOrganismeAsc($nomOrganismeAsc) { $this->nomOrganismeAsc = $nomOrganismeAsc; } /** * Get nomOrganismeAsc * * @return string */ public function getNomOrganismeAsc() { return $this->nomOrganismeAsc; } /** * Set nomClubAsc * * @param string $nomClubAsc */ public function setNomClubAsc($nomClubAsc) { $this->nomClubAsc = $nomClubAsc; } /** * Get nomClubAsc * * @return string */ public function getNomClubAsc() { return $this->nomClubAsc; } /** * Set roleCandOrgAsc * * @param string $roleCandOrgAsc */ public function setRoleCandOrgAsc($roleCandOrgAsc) { $this->roleCandOrgAsc = $roleCandOrgAsc; } /** * Get roleCandOrgAsc * * @return string */ public function getRoleCandOrgAsc() { return $this->roleCandOrgAsc; } /** * Set debutAdhesionAsc * * @param datetime $debutAdhesionAsc */ public function setDebutAdhesionAsc($debutAdhesionAsc) { $this->debutAdhesionAsc = $debutAdhesionAsc; } /** * Get debutAdhesionAsc * * @return datetime */ public function getDebutAdhesionAsc() { return $this->debutAdhesionAsc; } /** * Set finAdhesionAsc * * @param datetime $finAdhesionAsc */ public function setFinAdhesionAsc($finAdhesionAsc) { $this->finAdhesionAsc = $finAdhesionAsc; } /** * Get finAdhesionAsc * * @return datetime */ public function getFinAdhesionAsc() { return $this->finAdhesionAsc; } /** * Set codeCv * * @param MyApp\emploiBundle\Entity\PvJobCandCv $codeCv */ public function setCodeCv(\MyApp\emploiBundle\Entity\PvJobCandCv $codeCv) { $this->codeCv = $codeCv; } /** * Get codeCv * * @return MyApp\emploiBundle\Entity\PvJobCandCv */ public function getCodeCv() { return $this->codeCv; } }
cette commande elle me permet de générer les formulaires non ?
C'est normal je comprend maintenant : tu n'as pas la méthode : getId() et private $id !!
mais pour quoi Doctrine/Symfony 2 n'a pas générer cette la méthode : getId() et private $id; ?Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 /** * @var integer $id * * @ORM\Column(name="id", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; -------------- et ------------------ /** * Get id * * @return integer */ public function getId() { return $this->id; }
mon clé primaire est CodeAsc et il y a la fonction getAsc
Code:
1
2
3
4 public function getCodeAsc() { return $this->codeAsc; }
le champ codeAsc faut qu'il s'appelle id voila change les alors dans phpmyadmin juste les noms des champs qui possèdent la clé primaire tous en "id" et refais tout: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 PvJobCandAssociations: type: entity table: pv__job_cand_associations fields: id: // faut que codeAsc s'appelle id id: true type: integer unsigned: false nullable: false column: code_asc generator: strategy: IDENTITY nomOrganismeAsc: type: string length: 254 fixed: false nullable: true column: nom_organisme_asc nomClubAsc: type: string length: 254 fixed: false nullable: true column: nom_club_asc roleCandOrgAsc: type: string length: 254 fixed: false nullable: true column: role_cand_org_asc debutAdhesionAsc: type: datetime nullable: true column: debut_adhesion_asc finAdhesionAsc: type: datetime nullable: true column: fin_adhesion_asc manyToOne: codeCv: targetEntity: PvJobCandCv cascade: { } mappedBy: null inversedBy: null joinColumns: code_cv: referencedColumnName: code_cv orphanRemoval: false lifecycleCallbacks: { }
... etc Doctrine impose cela avant de mappés les tables faut s'y préparer ;)Code:
1
2
3 php app/console doctrine:mapping:convert --from-database yml src/MyApplication/MyBundle/Resources/config/doctrine/metadata/orm ...................
N'oublie pas d'effacer les fichiers .orm.yml dans /Resources/config/doctrine/metadata/orm/
lorsque modifier le clé primaire et j 'ai répété il m affiche un autre erreur
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 C:\wamp\www\portail>php app/console doctrine:generate:entities "MyAppemploiBundl e" Generating entities for bundle "MyAppemploiBundle" 'stty' n'est pas reconnu en tant que commande interne ou externe, un programme exécutable ou un fichier de commandes. [RuntimeException] Bundle "MyAppemploiBundle" does not contain any mapped entities. doctrine:generate:entities [--path="..."] [--no-backup] name C:\wamp\www\portail>
Modifier la clé primaire ?? la solution est de renommer un champ "tuto" dans une table ce champ possède la clé primaire en "id" c'est tout ! l'idée c'est d'avoir dans ta classe entité :
Code:
1
2
3
4
5
6
7 private $id; public function getId() { return $this->id; }
merci :Denfin j 'ai passé cette étape est ce que c 'est juste comme ca et comment ou je trouve les formulaire
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 C:\wamp\www\portail>php app/console generate:doctrine:crud Welcome to the Doctrine2 CRUD generator This command helps you generate CRUD controllers and templates. First, you need to give the entity for which you want to generate a CRUD. You can give an entity that does not exist yet and the wizard will help you defining it. You must use the shortcut notation like AcmeBlogBundle:Post. The Entity shortcut name: MyAppemploiBundle:PvJobCandAssociations By default, the generator creates two actions: list and show. You can also ask it to generate "write" actions: new, update, and delete. Do you want to generate the "write" actions [no]? Determine the format to use for the generated CRUD. Configuration format (yml, xml, php, or annotation) [annotation]: Determine the routes prefix (all the routes will be "mounted" under this prefix: /prefix/, /prefix/new, ...). Routes prefix [/pvjobcandassociations]: Summary before generation You are going to generate a CRUD controller for "MyAppemploiBundle:PvJobCandAsso ciations" using the "annotation" format. Do you confirm generation [yes]? CRUD generation Generating the CRUD code: OK You can now start using the generated code! C:\wamp\www\portail>
Bon :
les controlleur dans MyApp/emploiBundle/Controller
les formulaires dans MyApp/emploiBundle/Form
les vues dans MyApp/emploiBundle/Resources/views
les routes dans MyApp/emploiBundle/Resources/config/routing
pour mettre en place les routes faut modifier :
MyApp/emploiBundle/Resources/config/routing.yml tu definis par exemple :
tu met l'url suivant : http://localhost/portail/web/app_dev.php/route1Code:
1
2
3
4
5 Myappemploibundle_pvjobcandassociations: resource: "@MyAppemploiBundle/Resources/config/routing/pvjobcandassociations.yml" prefix: /route1
tu verras tes donnés s'affichent et tu pourra les lister, les modifier et les supprimer et tu aura tes forms
elle m 'affiche un erreur :cry:
Code:
1
2
3 Cannot import resource "@MyAppemploiBundle:/Resources/config/routing/pvjobcandassociations.yml" from "C:\wamp\www\portail\src\MyApp\emploiBundle/Resources/config/routing.yml". Make sure the "MyAppemploiBundle:/Resources/config/routing/pvjobcandassociations.yml" bundle is correctly registered and loaded in the application kernel class. 500 Internal Server Error - FileLoaderLoadException 1 linked Exception: InvalidArgumentException »
j 'ajoute sous C:\wamp\www\portail\src\MyApp\emploiBundle\Resources\config
routing.yml
ce code
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 MyAppemploiBundle_homepage: pattern: /hello/{name} defaults: { _controller: MyAppemploiBundle:Default:index }pvjobcandassociations: pattern: / defaults: { _controller: "MyAppemploiBundle:PvJobCandAssociations:index" } pvjobcandassociations_show: pattern: /{id}/show defaults: { _controller: "MyAppemploiBundle:PvJobCandAssociations:show" } pvjobcandassociations_new: pattern: /new defaults: { _controller: "MyAppemploiBundle:PvJobCandAssociations:new" } pvjobcandassociations_create: pattern: /create defaults: { _controller: "MyAppemploiBundle:PvJobCandAssociations:create" } requirements: { _method: post } pvjobcandassociations_edit: pattern: /{id}/edit defaults: { _controller: "MyAppemploiBundle:PvJobCandAssociations:edit" } pvjobcandassociations_update: pattern: /{id}/update defaults: { _controller: "MyAppemploiBundle:PvJobCandAssociations:update" } requirements: { _method: post } pvjobcandassociations_delete: pattern: /{id}/delete defaults: { _controller: "MyAppemploiBundle:PvJobCandAssociations:delete" } requirements: { _method: post }
c'est normal !! Non ajoute juste au fichier C:\wamp\www\portail\src\MyApp\emploiBundle\Resources\config
routing.yml ceci :
Il doit etre du genre :Code:
1
2
3
4 Myappemploibundle_pvjobcandassociations: resource: "@MyAppemploiBundle/Resources/config/routing/pvjobcandassociations.yml" prefix: /route1
et touche pas aux fichiers de MyAppemploiBundle:/Resources/config/routing plutot sur MyAppemploiBundle:/Resources/config/routing.ymlCode:
1
2
3
4
5
6
7
8 MyAppemploiBundle_homepage: pattern: /hello/{name} defaults: { _controller: MyAppemploiBundle:Default:index } Myappemploibundle_pvjobcandassociations: resource: "@MyAppemploiBundle/Resources/config/routing/pvjobcandassociations.yml" prefix: /route1
ajoute d'autre route : et change la resource chaque entité XXXX exploite un XXXX.yml dans le dossier MyAppemploiBundle:/Resources/config/routing
Et fais gaffe aux espaces avec le langage YAML pas de tabulation il faut laisser 4 fois espace (appuie 4 sur la touche espace du clavier ) ;)