Merge branch 'master' of github.com:doctrine/orm-documentation
This commit is contained in:
commit
a6cdafe85c
@ -453,15 +453,26 @@ For the commandline tool to work a cli-config.php file has to be present in the
|
||||
where you will execute the doctrine command. Its a fairly simple file:
|
||||
|
||||
[php]
|
||||
$cliConfig = new Doctrine\Common\Cli\Configuration();
|
||||
$cliConfig->setAttribute('em', $entityManager);
|
||||
$helperSet = new \Symfony\Components\Console\Helper\HelperSet(array(
|
||||
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($entityManager)
|
||||
));
|
||||
$cli->setHelperSet($helperSet);
|
||||
|
||||
You can then use your favorite console tool to call:
|
||||
You can then change into your project directory and call the Doctrine commandline tool:
|
||||
|
||||
[console]
|
||||
doctrine@my-desktop> cd myproject/
|
||||
doctrine@my-desktop> doctrine orm:schema-tool:create
|
||||
|
||||
> **NOTE**
|
||||
>
|
||||
> The `doctrine` command will only be present if you installed Doctrine from PEAR.
|
||||
> Otherwise you will have to dig into the `bin/doctrine.php` code of your Doctrine 2
|
||||
> directory to setup your doctrine commandline client.
|
||||
>
|
||||
> See the [Tools section of the manual](http://www.doctrine-project.org/projects/orm/2.0/docs/reference/tools/en)
|
||||
> on how to setup the Doctrine console correctly.
|
||||
|
||||
During the development you probably need to re-create the database several times when changing the Entity
|
||||
metadata. You can then either re-create the database:
|
||||
|
||||
|
@ -82,9 +82,9 @@ method which returns an array of events it should be subscribed to.
|
||||
Now when you dispatch an event any event subscribers will be notified for that event.
|
||||
|
||||
[php]
|
||||
$evm->dispatchEvent(TestEventSubscriber::preFoo);
|
||||
$evm->dispatchEvent(TestEvent::preFoo);
|
||||
|
||||
Now the test the `$eventSubscriber` instance to see if the `preFoo()` method was invoked.
|
||||
Now you can test the `$eventSubscriber` instance to see if the `preFoo()` method was invoked.
|
||||
|
||||
[php]
|
||||
if ($eventSubscriber->preFooInvoked) {
|
||||
@ -268,7 +268,7 @@ carefully since operations in the wrong event may produce lots of different erro
|
||||
lost updates/persists/removes.
|
||||
|
||||
For the described events that are also lifecycle callback events the restrictions
|
||||
apply aswell, with the additional restriction that you do not have access to the EntityManager
|
||||
apply as well, with the additional restriction that you do not have access to the EntityManager
|
||||
or UnitOfWork APIs inside these events.
|
||||
|
||||
+++ prePersist
|
||||
@ -290,7 +290,7 @@ The following restrictions apply to `prePersist`:
|
||||
* If you are using a PrePersist Identity Generator such as sequences the ID value
|
||||
will *NOT* be available within any PrePersist events.
|
||||
* Doctrine will not recognize changes made to relations in a pre persist event
|
||||
called by "reachibility" through a cascade persist unless you use the internal
|
||||
called by "reachability" through a cascade persist unless you use the internal
|
||||
`UnitOfWork` API. We do not recommend such operations in the persistence by
|
||||
reachability context, so do this at your own risk and possibly supported by unit-tests.
|
||||
|
||||
@ -316,7 +316,7 @@ been computed. This means, the `onFlush` event has access to the sets of:
|
||||
* Collections scheduled for update
|
||||
* Collections scheduled for removal
|
||||
|
||||
To make use of the onFlush event you have to be familiar with interal UnitOfWork API,
|
||||
To make use of the onFlush event you have to be familiar with the internal UnitOfWork API,
|
||||
which grants you access to the previously mentioned sets. See this example:
|
||||
|
||||
[php]
|
||||
|
@ -77,17 +77,24 @@ line installation utility.
|
||||
|
||||
To install just the `Common` package you can run the following command:
|
||||
|
||||
$ sudo pear install pear.doctrine-project.org/DoctrineCommon-2.0.0
|
||||
$ sudo pear install pear.doctrine-project.org/DoctrineCommon-<version>
|
||||
|
||||
If you want to use the Doctrine Database Abstraction Layer you can install it
|
||||
with the following command.
|
||||
|
||||
$ sudo pear install pear.doctrine-project.org/DoctrineDBAL-2.0.0
|
||||
$ sudo pear install pear.doctrine-project.org/DoctrineDBAL-<version>
|
||||
|
||||
Or, if you want to get the works and go for the ORM you can install it with the
|
||||
following command.
|
||||
|
||||
$ sudo pear install pear.doctrine-project.org/DoctrineORM-2.0.0
|
||||
$ sudo pear install pear.doctrine-project.org/DoctrineORM-<version>
|
||||
|
||||
> **NOTE**
|
||||
> The `<version>` tag above represents the version you want to install. For example the
|
||||
> current version at the time of writing this is `2.0.0BETA3` for the ORM, so you could
|
||||
> install it like the following:
|
||||
>
|
||||
> $ sudo pear install pear.doctrine-project.org/DoctrineORM-2.0.0BETA3
|
||||
|
||||
When you have a package installed via PEAR you can require and load the
|
||||
`ClassLoader` with the following code.
|
||||
|
@ -1,13 +1,13 @@
|
||||
++ The Doctrine Console
|
||||
|
||||
The Doctrine Console is a Command Line Interface tool for simplifying many common commands during the development of a project that uses Doctrine.
|
||||
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.
|
||||
|
||||
If you use Doctrine through SVN or a release package you need to copy the `doctrine` and `doctrine.php` files from the `tools/sandbox` or `bin` folder, respectively, to a location of your choice, for example a `tools` folder of your project.
|
||||
In addition you may need to edit `doctrine.php` and adjust some paths to the new environment. You may want to add require_once() statement at the top of doctrine.php to set up the include_path for Doctrine classes.
|
||||
You probably need to edit `doctrine.php` to adjust some paths to the new environment, most importantly the first line that includes the `Doctrine\Common\ClassLoader`.
|
||||
|
||||
+++ Getting Help
|
||||
|
||||
@ -17,8 +17,9 @@ Type `doctrine` on the command line and you should see an overview of the availa
|
||||
|
||||
+++ Configuration
|
||||
|
||||
Whenever the `doctrine` command line tool is invoked, it is only able to access Commands that were defined by developer. Dependency Injection (DI) is the responsable to inject support into this utility, but it is up to the developer define it.
|
||||
The Doctrine CLI tool from the bin/ folder already defines all the DBAL and ORM commands shipped with Doctrine.
|
||||
Whenever the `doctrine` command line tool is invoked, it can access alls Commands that were registered by developer.
|
||||
There is no auto-detection mechanism at work. The `bin\doctrine.php` file already registers all the commands that
|
||||
currently ship with 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 either the `db` or the `em` helpers to be defined in order to work correctly. Doctrine Console requires the definition of a HelperSet that is the DI tool to be injected in the Console.
|
||||
In case of a project that is dealing exclusively with DBAL, the ConnectionHelper is required:
|
||||
|
Loading…
x
Reference in New Issue
Block a user