Entity manager no definaty problems with Doctrine

Asked

Viewed 197 times

2

I’m having trouble with Doctrine when I try to generate entities it sends me a message saying

 **[InvalidArgumentException]       
     The helper "em" is not defined.** 

my configuration file is set this way

// bootstrap.php
//vamos configurar a chamada ao Entity Manager, o mais importante do Doctrine
// o Autoload é responsável por carregar as classes sem necessidade de incluí-las previamente
//require_once "/var/www/html/noc/vendor/autoload.php";
// o Doctrine utiliza namespaces em sua estrutura, por isto estes uses
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Configuration;

//
$root = "/var/www/html/uan/";
////onde irão ficar as entidades do projeto? Defina o caminho aqui
$entidades = array($root . "models/");
//
$isDevMode = TRUE;
//
////// configurações de conexão. Coloque aqui os seus dados
//$dbParams = array(
//    'driver' => 'pdo_mysql',
//    'user' => 'root',
//    'password' => 'elone',
//    'dbname' => 'ZAP',
//);
////
//////setando as configurações definidas anteriormente
$config = Setup::createAnnotationMetadataConfiguration($entidades, $isDevMode, NULL, NULL, FALSE);
//////criando o Entity Manager com base nas configurações de dev e banco de dados
////$entityManager = EntityManager::create($dbParams, $config);
//


$applicationMode = "desenvolvimento";


if ($applicationMode == "desenvolvimento") {
    $cache = new \Doctrine\Common\Cache\ArrayCache;
} else {
    $cache = new \Doctrine\Common\Cache\ApcCache;
}

$config = new Configuration();
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver($root . '/' . 'models/');
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setProxyDir($root . '/' . 'proxies/');
$config->setProxyNamespace('proxies');

if ($applicationMode == "desenvolvimento") {
    $config->setAutoGenerateProxyClasses(true);
} else {
    $config->setAutoGenerateProxyClasses(false);
}

$config = Setup::createAnnotationMetadataConfiguration($entidades, $isDevMode, NULL, NULL, FALSE);



$dbParams = array(
    'driver' => 'pdo_mysql',
    'user' => 'root',
    'password' => 'elone',
    'dbname' => 'ceafie',
);

$em = EntityManager::create($dbParams, $config);
$helpers = new Symfony\Component\Console\Helper\HelperSet(array(
    'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
    'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
        ));
  • Which command is using?

1 answer

0

I was able to solve the problem by reconfiguring Doctrine. I finished the documentation at this link I just followed the steps..

  • Don’t add "thank you" as an answer. Instead, vote for the answers you find useful. - From Review

  • @rubStackOverflow the author of the answer is the same as the question. And there is no "thank you" in the answer, the problem is answer only with link.

  • I was wrong @Diegof

Browser other questions tagged

You are not signed in. Login or sign up in order to post.