diff --git a/UPGRADE.md b/UPGRADE.md index aa5f20b19d6..3e453d7d78c 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,13 @@ # Upgrade to 2.12 +## Deprecated the `doctrine` binary. + +The documentation explains how the console tools can be bootstrapped for +standalone usage. + +The method `ConsoleRunner::printCliConfigTemplate()` is deprecated because it +was only useful in the context of the `doctrine` binary. + ## Deprecate omitting `$class` argument to `ORMInvalidArgumentException::invalidIdentifierBindingEntity()` To make it easier to identify understand the cause for that exception, it is @@ -13,6 +21,7 @@ multiple entity managers had been deprecated with 2.9 already. This leaves The `EntityManagerHelper` class with no purpose which is why it is now deprecated too. Applications that still rely on the `em` console helper, can easily recreate that class in their own codebase. + ## Deprecate custom repository classes that don't extend `EntityRepository` Although undocumented, it is currently possible to configure a custom repository diff --git a/bin/doctrine-pear.php b/bin/doctrine-pear.php index 4ac3f0015d9..85cb067667a 100644 --- a/bin/doctrine-pear.php +++ b/bin/doctrine-pear.php @@ -1,5 +1,14 @@ setCatchExceptions(true); - $cli->setHelperSet($helperSet); - Doctrine\ORM\Tools\Console\ConsoleRunner::addCommands($cli); - $cli->run(); +line interface. You can take a look at the +:doc:`tools chapter <../reference/tools>` for inspiration how to setup the cli. diff --git a/docs/en/reference/configuration.rst b/docs/en/reference/configuration.rst index 03a520ce8cb..47b0366a963 100644 --- a/docs/en/reference/configuration.rst +++ b/docs/en/reference/configuration.rst @@ -111,26 +111,6 @@ Setting up the Commandline Tool ------------------------------- Doctrine ships with a number of command line tools that are very helpful -during development. You can call this command from the Composer binary -directory: - -.. code-block:: sh - - $ php vendor/bin/doctrine - -You need to register your applications EntityManager to the console tool -to make use of the tasks by creating a ``cli-config.php`` file with the -following content: - -.. code-block:: php - - `. diff --git a/docs/en/reference/tools.rst b/docs/en/reference/tools.rst index f42b35ac0d2..eb9631695fe 100644 --- a/docs/en/reference/tools.rst +++ b/docs/en/reference/tools.rst @@ -7,24 +7,10 @@ Doctrine Console The Doctrine Console is a Command Line Interface tool for simplifying common administration tasks during the development of a project that uses ORM. -Take a look at the :doc:`Installation and Configuration ` -chapter for more information how to setup the console command. +For the following examples, we will set up the CLI as ``bin/doctrine``. -Display Help Information -~~~~~~~~~~~~~~~~~~~~~~~~ - -Type ``php vendor/bin/doctrine`` on the command line and you should see an -overview of the available commands or use the --help flag to get -information on the available commands. If you want to know more -about the use of generate entities for example, you can call: - -.. code-block:: php - - $> php vendor/bin/doctrine orm:generate-entities --help - - -Configuration -~~~~~~~~~~~~~ +Setting Up the Console +~~~~~~~~~~~~~~~~~~~~~~ Whenever the ``doctrine`` command line tool is invoked, it can access all Commands that were registered by a developer. There is no @@ -34,25 +20,33 @@ Doctrine DBAL and ORM. If you want to use additional commands you have to register them yourself. All the commands of the Doctrine Console require access to the -``EntityManager``. You have to inject it into the console application with -``ConsoleRunner::createHelperSet``. Whenever you invoke the Doctrine -binary, it searches the current directory for the file ``cli-config.php``. -This file contains the project-specific configuration. +``EntityManager``. You have to inject it into the console application. -Here is an example of a the project-specific ``cli-config.php``: +Here is an example of a the project-specific ``bin/doctrine`` binary. .. code-block:: php + #!/usr/bin/env php php bin/doctrine orm:generate-entities --help + Command Overview ~~~~~~~~~~~~~~~~ @@ -189,38 +195,35 @@ To create the schema use the ``create`` command: .. code-block:: php - $ php doctrine orm:schema-tool:create + $ php bin/doctrine orm:schema-tool:create To drop the schema use the ``drop`` command: .. code-block:: php - $ php doctrine orm:schema-tool:drop + $ php bin/doctrine orm:schema-tool:drop If you want to drop and then recreate the schema then use both options: .. code-block:: php - $ php doctrine orm:schema-tool:drop - $ php doctrine orm:schema-tool:create + $ php bin/doctrine orm:schema-tool:drop + $ php bin/doctrine orm:schema-tool:create As you would think, if you want to update your schema use the ``update`` command: .. code-block:: php - $ php doctrine orm:schema-tool:update + $ php bin/doctrine orm:schema-tool:update All of the above commands also accept a ``--dump-sql`` option that will output the SQL for the ran operation. .. code-block:: php - $ php doctrine orm:schema-tool:create --dump-sql - -Before using the orm:schema-tool commands, remember to configure -your cli-config.php properly. + $ php bin/doctrine orm:schema-tool:create --dump-sql Entity Generation ----------------- @@ -229,9 +232,9 @@ Generate entity classes and method stubs from your mapping information. .. code-block:: php - $ php doctrine orm:generate-entities - $ php doctrine orm:generate-entities --update-entities - $ php doctrine orm:generate-entities --regenerate-entities + $ php bin/doctrine orm:generate-entities + $ php bin/doctrine orm:generate-entities --update-entities + $ php bin/doctrine orm:generate-entities --regenerate-entities This command is not suited for constant usage. It is a little helper and does not support all the mapping edge cases very well. You still have to put work @@ -316,7 +319,7 @@ convert to and the path to generate it: .. code-block:: php - $ php doctrine orm:convert-mapping xml /path/to/mapping-path-converted-to-xml + $ php bin/doctrine orm:convert-mapping xml /path/to/mapping-path-converted-to-xml Reverse Engineering ------------------- @@ -366,7 +369,7 @@ You can also reverse engineer a database using the .. code-block:: php - $ php doctrine orm:convert-mapping --from-database yml /path/to/mapping-path-converted-to-yml + $ php bin/doctrine orm:convert-mapping --from-database yml /path/to/mapping-path-converted-to-yml .. note:: diff --git a/docs/en/tutorials/getting-started.rst b/docs/en/tutorials/getting-started.rst index d96a8c5f768..a9200997dd3 100644 --- a/docs/en/tutorials/getting-started.rst +++ b/docs/en/tutorials/getting-started.rst @@ -191,22 +191,35 @@ Generating the Database Schema Doctrine has a command-line interface that allows you to access the SchemaTool, a component that can generate a relational database schema based entirely on the -defined entity classes and their metadata. For this tool to work, a -``cli-config.php`` file must exist in the project root directory: +defined entity classes and their metadata. For this tool to work, you need to +create an executable console script as described in the +:doc:`tools chapter <../reference/tools>`. + +If you created the ``bootstrap.php`` file as described in the previous section, +that script could look like this: .. code-block:: php + #!/usr/bin/env php