Configuring Doctrine command-line tools

The Doctrine library is bundled with some useful command line tools. They provide many helpful features, including, but not limited to the ability to create database schema from entity mappings.

Composer has installed Doctrine's command line tools in the vendor/bin/ directory. But before being able to use them, a bit of configuration must be done. Command line tools internally use an Entity Manager. We need to tell them how to retrieve it.

Here, we just need to create one more file called cli-config.php in the config/ directory as follows:

 <?php // Doctrine CLI configuration file use Doctrine\ORM\Tools\Console\ConsoleRunner; require_once __DIR__.'/../src/bootstrap.php'; return ConsoleRunner::createHelperSet($entityManager); ...

Get Persistence in PHP with Doctrine ORM now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.