![]() |
|
The symfony and Doctrine bookChapter 1 - Getting Started |
|
You are currently reading "The symfony and Doctrine book" which is licensed under the GFDL license.

The symfony and Doctrine book does not explain in detail everything about Doctrine. It briefly touches on a few critical subjects that symfony utilizes the most. The Doctrine manual is still the best source of documentation for referencing everything that is Doctrine. It is recommended you read this book to get started and then utilize the Doctrine manual for referencing the specifics of using Doctrine. You can find the main Doctrine documentation here.

Doctrine is a PHP ORM (object relational mapper) for PHP 5.2.3+ that sits on top of a powerful PHP DBAL (database abstraction layer). One of its key features is the ability to optionally write database queries in an OO (object oriented) SQL-dialect called DQL inspired by Hibernate's HQL. This provides developers with a powerful alternative to SQL that maintains a maximum of flexibility without requiring needless code duplication.
In order to begin using Doctrine you must first enable it by editing your config/ProjectConfiguration.class.php setup() method to enable sfDoctrinePlugin and disable sfPropelPlugin.
public function setup() { $this->enablePlugins(array('sfDoctrinePlugin')); $this->disablePlugins(array('sfPropelPlugin')); }
If you prefer to have all plugins enabled by default, you can do the following:
public function setup() { $this->enableAllPluginsExcept(array('sfPropelPlugin', 'sfCompat10Plugin')); }
Though not recommended, Doctrine and Propel can be used side-by-side. Simply enable sfDoctrinePlugin without disabling sfPropelPlugin and you are good to go.
Below is the complete list of tasks available with the sfDoctrinePlugin. sfDoctrinePlugin offers all of the functionality of sfPropelPlugin, plus much more.
$ ./symfony list doctrine
Usage:
symfony [options] task_name [arguments]
Options:
--dry-run -n Do a dry run without executing actions.
--help -H Display this help message.
--quiet -q Do not log messages to standard output.
--trace -t Turn on invoke/execute tracing, enable full backtrace.
--version -V Display the program version.
Available tasks for the "doctrine" namespace:
:build-all Generates Doctrine model, SQL and initializes the database (doctrine-build-all)
:build-all-load Generates Doctrine model, SQL, initializes database, and load data (doctrine-build-all-load)
:build-all-reload Generates Doctrine model, SQL, initializes database, and load data (doctrine-build-all-reload)
:build-all-reload-test-all Generates Doctrine model, SQL, initializes database, load data and run all test suites (doctrine-build-all-reload-test-all)
:build-db Creates database for current model (doctrine-build-db)
:build-filters Creates filter form classes for the current model
:build-forms Creates form classes for the current model (doctrine-build-forms)
:build-model Creates classes for the current model (doctrine-build-model)
:build-schema Creates a schema from an existing database (doctrine-build-schema)
:build-sql Creates SQL for the current model (doctrine-build-sql)
:data-dump Dumps data to the fixtures directory (doctrine-dump-data)
:data-load Loads data from fixtures directory (doctrine-load-data)
:dql Execute a DQL query and view the results (doctrine-dql)
:drop-db Drops database for current model (doctrine-drop-db)
:generate-admin Generates a Doctrine admin module
:generate-migration Generate migration class (doctrine-generate-migration)
:generate-migrations-db Generate migration classes from existing database connections (doctrine-generate-migrations-db, doctrine-gen-migrations-from-db)
:generate-migrations-models Generate migration classes from an existing set of models (doctrine-generate-migrations-models, doctrine-gen-migrations-from-models)
:generate-module Generates a Doctrine module (doctrine-generate-crud, doctrine:generate-crud)
:generate-module-for-route Generates a Doctrine module for a route definition
:insert-sql Inserts SQL for current model (doctrine-insert-sql)
:migrate Migrates database to current/specified version (doctrine-migrate)
:rebuild-db Creates database for current model (doctrine-rebuild-db)
If you find a typo or an error, please register and open a ticket.
If you need support or have a technical question, please post to the official user mailing-list.