21.10.2015 Views

1-33

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Symfony2 – Franz Jordán 2011<br />

A list of available command will print out, many of which start with the doctrine: prefix. You can<br />

find out more information about any of these commands (or any Symfony command) by running<br />

thehelp command. For example, to get details about the doctrine:database:create task, run:<br />

php app/console help doctrine:database:create<br />

Some notable or interesting tasks include:<br />

doctrine:ensure-production-settings - checks to see if the current environment is<br />

configured efficiently for production. This should always be run in the prod environment:<br />

• php app/console doctrine:ensure-production-settings --env=prod<br />

doctrine:mapping:import - allows Doctrine to introspect an existing database and<br />

create mapping information. For more information, see How to generate Entities from an<br />

Existing Database.<br />

doctrine:mapping:info - tells you all of the entities that Doctrine is aware of and<br />

whether or not there are any basic errors with the mapping.<br />

doctrine:query:dql and doctrine:query:sql - allow you to execute DQL or SQL<br />

queries directly from the command line.<br />

To be able to load data fixtures to your database, you will need to have<br />

theDoctrineFixturesBundle bundle installed. To learn how to do it, read the<br />

"DoctrineFixturesBundle" entry of the documentation.<br />

Summary<br />

With Doctrine, you can focus on your objects and how they're useful in your application and<br />

worry about database persistence second. This is because Doctrine allows you to use any PHP<br />

object to hold your data and relies on mapping metadata information to map an object's data to<br />

a particular database table.<br />

And even though Doctrine revolves around a simple concept, it's incredibly powerful, allowing<br />

you to create complex queries and subscribe to events that allow you to take different actions as<br />

objects go through their persistence lifecycle.<br />

For more information about Doctrine, see the Doctrine section of the cookbook, which includes<br />

the following articles:<br />

DoctrineFixturesBundle<br />

Doctrine Extensions: Timestampable: Sluggable, Translatable, etc.<br />

102

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!