Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fixing commands in the reverse engineering example #2873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions cookbook/doctrine/reverse_engineering.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ folder.
The first step towards building entity classes from an existing database
is to ask Doctrine to introspect the database and generate the corresponding
metadata files. Metadata files describe the entity class to generate based on
tables fields.
table fields.

.. code-block:: bash

$ php app/console doctrine:mapping:convert xml ./src/Acme/BlogBundle/Resources/config/doctrine --from-database --force
$ php app/console doctrine:mapping:import --force AcmeBlogBundle xml

This command line tool asks Doctrine to introspect the database and generate
the XML metadata files under the ``src/Acme/BlogBundle/Resources/config/doctrine``
Expand All @@ -69,16 +69,16 @@ folder of your bundle. This generates two files: ``BlogPost.orm.xml`` and

.. tip::

It's also possible to generate metadata class in YAML format by changing the
first argument to ``yml``.
It's also possible to generate the metadata files in YAML format by changing
the last argument to ``yml``.

The generated ``BlogPost.orm.xml`` metadata file looks as follows:

.. code-block:: xml

<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="BlogPost" table="blog_post">
<entity name="Acme\BlogBundle\Entity\BlogPost" table="blog_post">
<id name="id" type="bigint" column="id">
<generator strategy="IDENTITY"/>
</id>
Expand All @@ -88,13 +88,6 @@ The generated ``BlogPost.orm.xml`` metadata file looks as follows:
</entity>
</doctrine-mapping>

Update the namespace in the ``name`` attribute of the ``entity`` element like
this:

.. code-block:: xml

<entity name="Acme\BlogBundle\Entity\BlogPost" table="blog_post">

Once the metadata files are generated, you can ask Doctrine to build related
entity classes by executing the following two commands.

Expand All @@ -103,14 +96,14 @@ entity classes by executing the following two commands.
$ php app/console doctrine:mapping:convert annotation ./src
$ php app/console doctrine:generate:entities AcmeBlogBundle

The first command generates entity classes with an annotations mapping. But
The first command generates entity classes with annotation mappings. But
if you want to use yml or xml mapping instead of annotations, you should
execute the second command only.

.. tip::

If you want to use annotations, you can safely delete the XML files after
running these two commands.
If you want to use annotations, you can safely delete the XML (or YAML) files
after running these two commands.

For example, the newly created ``BlogComment`` entity class looks as follow::

Expand Down