You are browsing a version that is no longer maintained.
The Doctrine Console is a Command Line Interface tool for simplifying common tasks during the development of a project that uses Doctrine PHPCR-ODM. It is built on the Symfony Console Component
If you have not set up the console yet, take a look at the Console Setup Section.
There are many commands, for example to import and export data, modify data in the repository, query or dump data from the repository or work with PHPCR workspaces.
Run the console without any arguments to see a list of all commands. The commands are self documenting. See the next section how to get help.
PHPCR-ODM specific commands start with
If you use the PHPCR-ODM bundle in Symfony, all commands will be prefixed
./vendor/bin/phpcrodm 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 the register command for example, call:
$ ./vendor/bin/phpcrodm help doctrine:phpcr:register-system-node-types
If you are using jackalope-jackrabbit, you also have a command to start and stop the jackrabbit server:
jackalope:run:jackrabbitStart and stop the Jackrabbit server
If you are using jackalope-doctrine-dbal, you have a command to initialize the database:
jackalope:init:dbalPrepare the database for Jackalope Doctrine DBAL
This command needs to be run once on a new repository to prepare it for use with the PHPCR-ODM. Failing to do so will throw you errors when you try to store a document that uses a node type different from nt:unstructured, like a file or folder.
Convert mapping information between supported formats.
This is an execute one-time command. It should not be necessary for you to call this method multiple times, especially when using the
Converting an existing database schema into mapping files only solves about 70-80% of the necessary mapping information. Additionally the detection from an existing database cannot detect inverse associations, inheritance types, entities with foreign keys as primary keys and many of the semantical operations on associations such as cascade.
There is no need to convert YAML or XML mapping files to annotations every time you make changes. All mapping drivers are first class citizens in Doctrine 2 and can be used as runtime mapping for the ORM. See the docs on XML and YAML Mapping for an example how to register this metadata drivers as primary mapping source.
To convert some mapping information between the various supported formats you can use the
ClassMetadataExporterto get exporter instances for the different formats:
$cme = new \Doctrine\ORM\Tools\Export\ClassMetadataExporter();
Once you have a instance you can use it to get an exporter. For example, the yml exporter:
$exporter = $cme->getExporter('yml', '/path/to/export/yml');
Now you can export some
$classes = array( $em->getClassMetadata('Entities\User'), $em->getClassMetadata('Entities\Profile') ); $exporter->setMetadata($classes); $exporter->export();
This functionality is also available from the command line to convert your loaded mapping information to another format. The
orm:convert-mappingcommand accepts two arguments, the type to convert to and the path to generate it:
$ php doctrine orm:convert-mapping xml /path/to/mapping-path-converted-to-xml
You can also add your own commands on-top of the Doctrine supported tools by adding them to your binary.
To include a new command in the console, either build your own console file
bin/phpcrodm.php into your project and add things as needed.
Read more on the Symfony Console Component in the official symfony documentation.