Trouble with PHP Doctrine: The EntityManager is not an instance of Doctrine\ORM\EntityManager; instead, it is a boolean

30 Views Asked by At

I've been stuck for a while with that problem. is the first time i work with php and orm doctrine so I'm very lost. The thing is that the response im getting from bootsrap.php EntityManager is a boolean and is supposed to be a instance of EntityManager. I really dont know what im doing wrong. Here is my bootsrap.php.

<?php
// bootstrap.php
require_once "vendor/autoload.php";

use Doctrine\DBAL\DriverManager;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\ORMSetup;

$paths = [__DIR__ . "/src"]; 
$isDevMode = false;

// the connection configuration
$dbParams = [
    'driver'   => 'pdo_mysql',
    'user'     => 'root',
    'password' => '',
    'dbname'   => 'huerto',
];

$config = ORMSetup::createAttributeMetadataConfiguration($paths, $isDevMode);
$connection = DriverManager::getConnection($dbParams, $config);
$entityManager = new EntityManager($connection, $config);


and thats my bin/doctrine

#!/usr/bin/env php
<?php

use Doctrine\ORM\Tools\Console\ConsoleRunner;

require_once __DIR__ . '/../bootstrap.php';

$entityManager = require_once __DIR__ . '/../bootstrap.php';

if (!($entityManager instanceof Doctrine\ORM\EntityManager)) {
    throw new \Exception('$entityManager is not a valid instance of Doctrine\ORM\EntityManager');
}


$helperSet = ConsoleRunner::createHelperSet($entityManager);

$commands = [];
ConsoleRunner::run($helperSet, $commands);

It will be amazing if someone can help me with that. i tried to change many things on the code but my EntityManager still beeing a boolean.

0

There are 0 best solutions below