Skip to content

Commit e4ce75a

Browse files
Majkl578lcobucci
authored andcommitted
Remove code generation tools & commands
1 parent c4eb2b0 commit e4ce75a

26 files changed

+15
-6607
lines changed

UPGRADE.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Upgrade to 3.0
22

3+
## BC Break: Removed code generators and related console commands
4+
5+
These console commands have been removed:
6+
7+
* `orm:convert-mapping`
8+
* `orm:generate:entities`
9+
* `orm:generate-repositories`
10+
11+
These classes have been removed:
12+
13+
* `Doctrine\ORM\Tools\EntityGenerator`
14+
* `Doctrine\ORM\Tools\EntityRepositoryGenerator`
15+
16+
Whole Doctrine\ORM\Tools\Export namespace with all its members has been removed as well.
17+
318
## BC Break: proxies no longer implement `Doctrine\ORM\Proxy\Proxy`
419

520
Proxy objects no longer implement `Doctrine\ORM\Proxy\Proxy` nor

docs/en/reference/faq.rst

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -143,23 +143,6 @@ If you set a many-to-one or one-to-one association target-entity to any parent c
143143
an inheritance hierarchy Doctrine does not know what PHP class the foreign is actually of.
144144
To find this out it has to execute a SQL query to look this information up in the database.
145145

146-
EntityGenerator
147-
---------------
148-
149-
Why does the EntityGenerator not do X?
150-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
151-
152-
The EntityGenerator is not a full fledged code-generator that solves all tasks. Code-Generation
153-
is not a first-class priority in Doctrine 2 anymore (compared to Doctrine 1). The EntityGenerator
154-
is supposed to kick-start you, but not towards 100%.
155-
156-
Why does the EntityGenerator not generate inheritance correctly?
157-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
158-
159-
Just from the details of the discriminator map the EntityGenerator cannot guess the inheritance hierarchy.
160-
This is why the generation of inherited entities does not fully work. You have to adjust some additional
161-
code to get this one working correctly.
162-
163146
Performance
164147
-----------
165148

docs/en/reference/tools.rst

Lines changed: 0 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,10 @@ The following Commands are currently available:
109109
cache drivers.
110110
- ``orm:convert-d1-schema`` Converts Doctrine 1.X schema into a
111111
Doctrine 2.X schema.
112-
- ``orm:convert-mapping`` Convert mapping information between
113-
supported formats.
114112
- ``orm:ensure-production-settings`` Verify that Doctrine is
115113
properly configured for a production environment.
116-
- ``orm:generate-entities`` Generate entity classes and method
117-
stubs from your mapping information.
118114
- ``orm:generate-proxies`` Generates proxy classes for entity
119115
classes.
120-
- ``orm:generate-repositories`` Generate repository classes from
121-
your mapping information.
122116
- ``orm:run-dql`` Executes arbitrary DQL directly from the command
123117
line.
124118
- ``orm:schema-tool:create`` Processes the schema and either
@@ -135,10 +129,7 @@ For these commands are also available aliases:
135129

136130

137131
- ``orm:convert:d1-schema`` is alias for ``orm:convert-d1-schema``.
138-
- ``orm:convert:mapping`` is alias for ``orm:convert-mapping``.
139-
- ``orm:generate:entities`` is alias for ``orm:generate-entities``.
140132
- ``orm:generate:proxies`` is alias for ``orm:generate-proxies``.
141-
- ``orm:generate:repositories`` is alias for ``orm:generate-repositories``.
142133

143134
.. note::
144135

@@ -261,162 +252,6 @@ your cli-config.php properly.
261252
(or mapping files), i.e.
262253
``new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em, $mappingPaths);``
263254

264-
Entity Generation
265-
-----------------
266-
267-
Generate entity classes and method stubs from your mapping information.
268-
269-
.. code-block:: php
270-
271-
$ php doctrine orm:generate-entities
272-
$ php doctrine orm:generate-entities --update-entities
273-
$ php doctrine orm:generate-entities --regenerate-entities
274-
275-
This command is not suited for constant usage. It is a little helper and does
276-
not support all the mapping edge cases very well. You still have to put work
277-
in your entities after using this command.
278-
279-
It is possible to use the EntityGenerator on code that you have already written. It will
280-
not be lost. The EntityGenerator will only append new code to your
281-
file and will not delete the old code. However this approach may still be prone
282-
to error and we suggest you use code repositories such as GIT or SVN to make
283-
backups of your code.
284-
285-
It makes sense to generate the entity code if you are using entities as Data
286-
Access Objects only and don't put much additional logic on them. If you are
287-
however putting much more logic on the entities you should refrain from using
288-
the entity-generator and code your entities manually.
289-
290-
.. note::
291-
292-
Even if you specified Inheritance options in your
293-
XML or YAML Mapping files the generator cannot generate the base and
294-
child classes for you correctly, because it doesn't know which
295-
class is supposed to extend which. You have to adjust the entity
296-
code manually for inheritance to work!
297-
298-
299-
Convert Mapping Information
300-
---------------------------
301-
302-
Convert mapping information between supported formats.
303-
304-
This is an **execute one-time** command. It should not be necessary for
305-
you to call this method multiple times, especially when using the ``--from-database``
306-
flag.
307-
308-
Converting an existing database schema into mapping files only solves about 70-80%
309-
of the necessary mapping information. Additionally the detection from an existing
310-
database cannot detect inverse associations, inheritance types,
311-
entities with foreign keys as primary keys and many of the
312-
semantical operations on associations such as cascade.
313-
314-
.. note::
315-
316-
There is no need to convert YAML or XML mapping files to annotations
317-
every time you make changes. All mapping drivers are first class citizens
318-
in Doctrine 2 and can be used as runtime mapping for the ORM. See the
319-
docs on XML and YAML Mapping for an example how to register this metadata
320-
drivers as primary mapping source.
321-
322-
To convert some mapping information between the various supported
323-
formats you can use the ``ClassMetadataExporter`` to get exporter
324-
instances for the different formats:
325-
326-
.. code-block:: php
327-
328-
<?php
329-
$cme = new \Doctrine\ORM\Tools\Export\ClassMetadataExporter();
330-
331-
Once you have a instance you can use it to get an exporter. For
332-
example, the yml exporter:
333-
334-
.. code-block:: php
335-
336-
<?php
337-
$exporter = $cme->getExporter('yml', '/path/to/export/yml');
338-
339-
Now you can export some ``ClassMetadata`` instances:
340-
341-
.. code-block:: php
342-
343-
<?php
344-
$classes = array(
345-
$em->getClassMetadata('Entities\User'),
346-
$em->getClassMetadata('Entities\Profile')
347-
);
348-
$exporter->setMetadata($classes);
349-
$exporter->export();
350-
351-
This functionality is also available from the command line to
352-
convert your loaded mapping information to another format. The
353-
``orm:convert-mapping`` command accepts two arguments, the type to
354-
convert to and the path to generate it:
355-
356-
.. code-block:: php
357-
358-
$ php doctrine orm:convert-mapping xml /path/to/mapping-path-converted-to-xml
359-
360-
Reverse Engineering
361-
-------------------
362-
363-
You can use the ``DatabaseDriver`` to reverse engineer a database
364-
to an array of ``ClassMetadata`` instances and generate YAML, XML, etc. from them.
365-
366-
.. note::
367-
368-
Reverse Engineering is a **one-time** process that can get you started with a project.
369-
Converting an existing database schema into mapping files only detects about 70-80%
370-
of the necessary mapping information. Additionally the detection from an existing
371-
database cannot detect inverse associations, inheritance types,
372-
entities with foreign keys as primary keys and many of the
373-
semantical operations on associations such as cascade.
374-
375-
First you need to retrieve the metadata instances with the
376-
``DatabaseDriver``:
377-
378-
.. code-block:: php
379-
380-
<?php
381-
$em->getConfiguration()->setMetadataDriverImpl(
382-
new \Doctrine\ORM\Mapping\Driver\DatabaseDriver(
383-
$em->getConnection()->getSchemaManager()
384-
)
385-
);
386-
387-
$cmf = new \Doctrine\ORM\Tools\DisconnectedClassMetadataFactory();
388-
$cmf->setEntityManager($em);
389-
$metadata = $cmf->getAllMetadata();
390-
391-
Now you can get an exporter instance and export the loaded metadata
392-
to yml:
393-
394-
.. code-block:: php
395-
396-
<?php
397-
$cme = new \Doctrine\ORM\Tools\Export\ClassMetadataExporter();
398-
$exporter = $cme->getExporter('yml', '/path/to/export/yml');
399-
$exporter->setMetadata($metadata);
400-
$exporter->export();
401-
402-
You can also reverse engineer a database using the
403-
``orm:convert-mapping`` command:
404-
405-
.. code-block:: php
406-
407-
$ php doctrine orm:convert-mapping --from-database yml /path/to/mapping-path-converted-to-yml
408-
409-
.. note::
410-
411-
Reverse Engineering is not always working perfectly
412-
depending on special cases. It will only detect Many-To-One
413-
relations (even if they are One-To-One) and will try to create
414-
entities from Many-To-Many tables. It also has problems with naming
415-
of foreign keys that have multiple column names. Any Reverse
416-
Engineered Database-Schema needs considerable manual work to become
417-
a useful domain model.
418-
419-
420255
Runtime vs Development Mapping Validation
421256
-----------------------------------------
422257

0 commit comments

Comments
 (0)