@@ -41,7 +41,7 @@ In this case, you'll need a ``Category`` class, and a way to relate a
41
41
42
42
Start by creating a ``Category `` entity with a ``name `` field:
43
43
44
- .. code-block :: terminal
44
+ .. code-block :: bash
45
45
46
46
$ php bin/console make:entity Category
47
47
@@ -64,6 +64,8 @@ Start by creating a ``Category`` entity with a ``name`` field:
64
64
This will generate your new entity class::
65
65
66
66
// src/Entity/Category.php
67
+ namespace App\Entity;
68
+
67
69
// ...
68
70
69
71
class Category
@@ -99,7 +101,7 @@ the ``ManyToOne`` annotation. You can do this by hand, or by using the ``make:en
99
101
command, which will ask you several questions about your relationship. If you're
100
102
not sure of the answer, don't worry! You can always change the settings later:
101
103
102
- .. code-block :: terminal
104
+ .. code-block :: bash
103
105
104
106
$ php bin/console make:entity
105
107
@@ -144,6 +146,7 @@ the ``Product`` entity (and getter & setter methods):
144
146
.. code-block :: php-annotations
145
147
146
148
// src/Entity/Product.php
149
+ namespace App\Entity;
147
150
148
151
// ...
149
152
class Product
@@ -214,7 +217,8 @@ class that will hold these objects:
214
217
.. code-block :: php-annotations
215
218
216
219
// src/Entity/Category.php
217
-
220
+ namespace App\Entity;
221
+
218
222
// ...
219
223
use Doctrine\Common\Collections\ArrayCollection;
220
224
use Doctrine\Common\Collections\Collection;
@@ -310,8 +314,10 @@ Saving Related Entities
310
314
311
315
Now you can see this new code in action! Imagine you're inside a controller::
312
316
317
+ // src/Controller/ProductController.php
318
+ namespace App/Controller;
319
+
313
320
// ...
314
-
315
321
use App\Entity\Category;
316
322
use App\Entity\Product;
317
323
use Symfony\Component\HttpFoundation\Response;
0 commit comments