Tools

Doctrine Console

The Doctrine Console is a Command Line Interface tool for simplifying common tasks during the development of a project that uses Doctrine PHPCR-ODM.

Take a look at the last section of Installation and Configuration for more information how to setup the console command.

Getting Help

Type bin/phpcr 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:

phpcr doctrine:phpcr:register-system-node-types --help

Configuration

To use the commands, you need to define the phpcr binary.

If you installed Doctrine PHPCR-ODM through Composer, then the phpcr script is available to you in the bin-dir, by default at vendor/bin/phpcr.

If you installed Doctrine PHPCR-ODM by some other means, copy bin/phpcr from the phpcr-odm folder and put it into your project directory.

Command Overview

The following Commands are currently available:

  • help Displays help for a command (?)
  • list Lists commands
  • doctrine:phpcr:register-system-node-types Register system node types in the PHPCR repository
  • doctrine:phpcr:mapping:info Shows basic information about all mapped documents
  • phpcr:import Import xml data into the repository, either in JCR system view format or arbitrary xml
  • phpcr:export Export nodes from the repository, either to the JCR system view format or the document view format
  • phpcr:dump Dump the content repository
  • phpcr:purge Remove all content from the repository
  • phpcr:query Execute a JCR SQL2 statement
  • phpcr:register-node-types Register node types in the PHPCR repository
  • phpcr:workspace:create Create a workspace in the configured repository
  • phpcr:workspace:list List all available workspaces in the configured repository

Note

The commands prefixed with only phpcr come from the phpcr-utils and are not specific to Doctrine PHPCR-ODM. If you use the PHPCR-ODM bundle in Symfony2, all commands are prefixed with doctrine:phpcr.

Jackrabbit specific commands

If you are using jackalope-jackrabbit, you also have a command to start and stop the jackrabbit server:

  • jackalope:run:jackrabbit Start and stop the Jackrabbit server

Doctrine DBAL specific commands

If you are using jackalope-doctrine-dbal, you have a command to initialize the database:

  • jackalope:init:dbal Prepare the database for Jackalope Doctrine DBAL

Register system node types

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.

Adding own commands

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 on Doctrine Console, you just need to add your command to the list of commands to provide in bin/phpcr.




Fork me on GitHub