From 65e2f60b40feaad8cbce1eb2ef3c7df3c54374e1 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 16 Jun 2012 11:57:56 +0200 Subject: [PATCH] Rework configuration and tools section to include Composer --- en/reference/configuration.rst | 126 ++++++++++++++++++++--------- en/reference/tools.rst | 143 ++++++++++++--------------------- 2 files changed, 138 insertions(+), 131 deletions(-) diff --git a/en/reference/configuration.rst b/en/reference/configuration.rst index fe0b7bb0c..6d4f291a7 100644 --- a/en/reference/configuration.rst +++ b/en/reference/configuration.rst @@ -1,18 +1,40 @@ Configuration ============= -Bootstrapping -------------- - Bootstrapping Doctrine is a relatively simple procedure that -roughly exists of just 2 steps: - +roughly exists of four steps: +- Installation - Making sure Doctrine class files can be loaded on demand. - Obtaining an EntityManager instance. +- Optional: Configuration of the Console Tool + +Installation +------------ + +`Composer `_ is the suggested installation method for Doctrine. +Define the following requirement in your ``composer.json`` file: + + { + "require": { + "doctrine/orm": "*" + } + } + +Then run the composer command. Class loading -~~~~~~~~~~~~~ +------------- + +Autoloading is taken care of by Composer. You just have to include the composer autoload file in your project: + +.. code-block:: php + + setCatchExceptions(true); + $cli->setHelperSet($helperSet); + Doctrine\ORM\Tools\Console\ConsoleRunner::addCommands($cli); + $cli->run(); diff --git a/en/reference/tools.rst b/en/reference/tools.rst index 25d591df7..69babfc27 100644 --- a/en/reference/tools.rst +++ b/en/reference/tools.rst @@ -8,15 +8,8 @@ The Doctrine Console is a Command Line Interface tool for simplifying common tasks during the development of a project that uses Doctrine 2. -Installation -~~~~~~~~~~~~ - -If you installed Doctrine 2 through PEAR, the ``doctrine`` command -line tool should already be available to you. Y - -In any other case you should create a project specific doctrine command -on your own. This is a combination of the PEAR ``doctrine`` commands -code and some of your own bootstrap code. +Take a look at the `Configuration ` for more +information how to setup the console command. Getting Help ~~~~~~~~~~~~ @@ -30,23 +23,6 @@ about the use of generate entities for example, you can call: doctrine orm:generate-entities --help -Setting up the Console ----------------------- - -Doctrine uses the Symfony Console component for generating the command -line interface. You can take a look at the ``bin/doctrine.php`` -script and the ``Doctrine\ORM\Tools\Console\ConsoleRunner`` command -for inspiration how to setup the cli. - -In general the required code looks like this: - -.. code-block:: php - - $cli = new Application('Doctrine Command Line Interface', \Doctrine\ORM\Version::VERSION); - $cli->setCatchExceptions(true); - $cli->setHelperSet($helperSet); - Doctrine\ORM\Tools\Console\ConsoleRunner::addCommands($cli); - $cli->run(); Configuration (PEAR) ~~~~~~~~~~~~~~~~~~~~ @@ -94,18 +70,10 @@ sample ``cli-config.php`` file looks as follows: new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), @@ -117,7 +85,6 @@ script will ultimately use. The Doctrine Binary will automatically find the first instance of HelperSet in the global variable namespace and use this. - .. note:: You have to adjust this snippet for your specific application or framework @@ -136,22 +103,15 @@ there whenever you want to access the Doctrine console. new ConnectionHelper($em->getConnection()), @@ -160,50 +120,6 @@ there whenever you want to access the Doctrine console. ConsoleRunner::run($helperSet); -Adding own commands -~~~~~~~~~~~~~~~~~~~ - -You can also add your own commands on-top of the Doctrine supported -tools if you are using a manually built (Non-PEAR) binary. - -To include a new command on Doctrine Console, you need to do modify the -``doctrine.php`` file a little: - -.. code-block:: php - - setCatchExceptions(true); - $cli->setHelperSet($helperSet); - - // Register All Doctrine Commands - ConsoleRunner::addCommands($cli); - - // Register your own command - $cli->addCommand(new \MyProject\Tools\Console\Commands\MyCustomCommand); - - // Runs console application - $cli->run(); - -Additionally, include multiple commands (and overriding previously -defined ones) is possible through the command: - -.. code-block:: php - - addCommands(array( - new \MyProject\Tools\Console\Commands\MyCustomCommand(), - new \MyProject\Tools\Console\Commands\SomethingCommand(), - new \MyProject\Tools\Console\Commands\AnotherCommand(), - new \MyProject\Tools\Console\Commands\OneMoreCommand(), - )); Command Overview ~~~~~~~~~~~~~~~~ @@ -518,4 +434,47 @@ You can also reverse engineer a database using the a useful domain model. +Adding own commands +------------------- +You can also add your own commands on-top of the Doctrine supported +tools if you are using a manually built (Non-PEAR) binary. + +To include a new command on Doctrine Console, you need to do modify the +``doctrine.php`` file a little: + +.. code-block:: php + + setCatchExceptions(true); + $cli->setHelperSet($helperSet); + + // Register All Doctrine Commands + ConsoleRunner::addCommands($cli); + + // Register your own command + $cli->addCommand(new \MyProject\Tools\Console\Commands\MyCustomCommand); + + // Runs console application + $cli->run(); + +Additionally, include multiple commands (and overriding previously +defined ones) is possible through the command: + +.. code-block:: php + + addCommands(array( + new \MyProject\Tools\Console\Commands\MyCustomCommand(), + new \MyProject\Tools\Console\Commands\SomethingCommand(), + new \MyProject\Tools\Console\Commands\AnotherCommand(), + new \MyProject\Tools\Console\Commands\OneMoreCommand(), + ));