June 2017
Intermediate to advanced
394 pages
8h 52m
English
First of all, we need to require Doctrine through Composer. At the root folder of the project, the command below has to be executed:
> php composer.phar require "doctrine/orm=^2.5"
Then, these lines will allow you to set up Doctrine:
require_once '/path/to/vendor/autoload.php';use Doctrine\ORM\Tools\Setup;use Doctrine\ORM\EntityManager;$paths = ['/path/to/entity-files'];$isDevMode = false;// the connection configuration$dbParams = [ 'driver' => 'pdo_mysql', 'user' => 'the_database_username', 'password' => 'the_database_password', 'dbname' => 'the_database_name',];$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);$entityManager = EntityManager::create($dbParams, $config);
Read now
Unlock full access