· 6 years ago · Mar 27, 2019, 11:24 PM
1 * @ORM\GeneratedValue() autoinkrementacja
2
3Admins-MBP:php lukaszsokolowski$ php bin/console make:entity
4
5 Class name of the entity to create or update (e.g. TinyKangaroo):
6 > Product
7
8 created: src/Entity/Product.php
9 created: src/Repository/ProductRepository.php
10
11 Entity generated! Now let's add some fields!
12 You can always add more fields later manually or by re-running this command.
13
14 New property name (press <return> to stop adding fields):
15 > name
16
17 Field type (enter ? to see all types) [string]:
18 > ?
19
20Main types
21 * string
22 * text
23 * boolean
24 * integer (or smallint, bigint)
25 * float
26
27Relationships / Associations
28 * relation (a wizard 🧙 will help you build the relation)
29 * ManyToOne
30 * OneToMany
31 * ManyToMany
32 * OneToOne
33
34Array/Object Types
35 * array (or simple_array)
36 * json
37 * object
38 * binary
39 * blob
40
41Date/Time Types
42 * datetime (or datetime_immutable)
43 * datetimetz (or datetimetz_immutable)
44 * date (or date_immutable)
45 * time (or time_immutable)
46 * dateinterval
47
48Other Types
49 * json_array
50 * decimal
51 * guid
52
53
54 Field type (enter ? to see all types) [string]:
55 > string
56
57 Field length [255]:
58 > 190
59
60 Can this field be null in the database (nullable) (yes/no) [no]:
61 > no
62
63 updated: src/Entity/Product.php
64
65 Add another property? Enter the property name (or press <return> to stop adding fields):
66 > description
67
68 Field type (enter ? to see all types) [string]:
69 > text
70
71 Can this field be null in the database (nullable) (yes/no) [no]:
72 > no
73
74 updated: src/Entity/Product.php
75
76 Add another property? Enter the property name (or press <return> to stop adding fields):
77 >
78
79
80
81 Success!
82
83
84 Next: When you're ready, create a migration with make:migration
85
86Admins-MBP:php lukaszsokolowski$ php bin/console make:migration
87
88
89 Success!
90
91
92 Next: Review the new migration "src/Migrations/Version20190320153246.php"
93 Then: Run the migration with php bin/console doctrine:migrations:migrate
94 See https://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html
95Admins-MBP:php lukaszsokolowski$ php bin/console doctrine:migrations:migrate
96
97 Application Migrations
98
99
100WARNING! You are about to execute a database migration that could result in schema changes and data loss. Are you sure you wish to continue? (y/n)y
101Migrating up to 20190320153246 from 0
102
103 ++ migrating 20190320153246
104
105 -> CREATE TABLE product (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(190) NOT NULL, description LONGTEXT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB
106
107 ++ migrated (took 105.8ms, used 14M memory)
108
109 ------------------------
110
111 ++ finished in 110.6ms
112 ++ used 14M memory
113 ++ 1 migrations executed
114 ++ 1 sql queries
115Admins-MBP:php lukaszsokolowski$ php bin/console make:entity
116
117 Class name of the entity to create or update (e.g. BraveElephant):
118 > Category
119
120 created: src/Entity/Category.php
121 created: src/Repository/CategoryRepository.php
122
123 Entity generated! Now let's add some fields!
124 You can always add more fields later manually or by re-running this command.
125
126 New property name (press <return> to stop adding fields):
127 > name
128
129 Field type (enter ? to see all types) [string]:
130 > string
131
132 Field length [255]:
133 > 190
134
135 Can this field be null in the database (nullable) (yes/no) [no]:
136 > no
137
138 updated: src/Entity/Category.php
139
140 Add another property? Enter the property name (or press <return> to stop adding fields):
141 >
142
143
144
145 Success!
146
147
148 Next: When you're ready, create a migration with make:migration
149
150Admins-MBP:php lukaszsokolowski$ php bin/console make:entity
151
152 Class name of the entity to create or update (e.g. BravePizza):
153 > Category
154
155 Your entity already exists! So let's add some new fields!
156
157 New property name (press <return> to stop adding fields):
158 > products
159
160 Field type (enter ? to see all types) [string]:
161 >
162Admins-MBP:php lukaszsokolowski$ php bin/console make:entity
163
164 Class name of the entity to create or update (e.g. TinyElephant):
165 > Product
166
167 Your entity already exists! So let's add some new fields!
168
169 New property name (press <return> to stop adding fields):
170 > category
171
172 Field type (enter ? to see all types) [string]:
173 > ManyToOne
174
175 What class should this entity be related to?:
176 > Category
177
178 Is the Product.category property allowed to be null (nullable)? (yes/no) [yes]:
179 > no
180
181 Do you want to add a new property to Category so that you can access/update Product objects from it - e.g. $category->getProducts()? (yes/no) [yes]:
182 > yes
183
184 A new property will also be added to the Category class so that you can access the related Product objects from it.
185
186 New field name inside Category [products]:
187 > products
188
189 Do you want to activate orphanRemoval on your relationship?
190 A Product is "orphaned" when it is removed from its related Category.
191 e.g. $category->removeProduct($product)
192
193 NOTE: If a Product may *change* from one Category to another, answer "no".
194
195 Do you want to automatically delete orphaned App\Entity\Product objects (orphanRemoval)? (yes/no) [no]:
196 > no
197
198 updated: src/Entity/Product.php
199 updated: src/Entity/Category.php
200
201 Add another property? Enter the property name (or press <return> to stop adding fields):
202 >
203
204
205
206 Success!
207
208
209 Next: When you're ready, create a migration with make:migration
210
211Admins-MBP:php lukaszsokolowski$