Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Aula 2 atividade 5 - Erro na execução do comando vendor/bin/doctrine.bat orm:info

Boa noite pessoal, tudo bom?

Estou tendo problemas em rodar o comando vendor/bin/doctrine.bat orm:info

Aparece o erro abaixo

$ vendor/bin/doctrine.bat orm:info

 Found 1 mapped entities:


In AbstractMySQLDriver.php line 128:

  An exception occurred in driver: could not find driver


In Exception.php line 18:

  could not find driver


In PDOConnection.php line 38:

  could not find driver


orm:info

Minha EntityManagerFactory.php

<?php 

namespace Alura\Doctrine\Helper;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\Setup;


class EntityManagerFactory
{
   /**
    * @return EntityManagerInterface
    * @throws \Doctrine\ORM\ORMException
    */
   public function getEntityManager(): EntityManagerInterface
   {
      $rootDir = __DIR__ . '/../..';
      $config = Setup::createAnnotationMetadataConfiguration(
         [$rootDir . '/src']
      );

      $connection = [
         'dbname' => 'alura_doctrine',
         'user' => 'root',
         'password' => '',
         'host' => 'localhost',
         'driver' => 'pdo_mysql',
         'path' => $rootDir . '/var/data/banco.sql'
      ];
      return EntityManager::create($connection, $config);
   }
}

E a minha Entity Aluno

<?php

namespace Alura\Doctrine\Entity;

/**
 * @Entity
 */
class Aluno
{
   /**
    * @Id
    * @GeneratedValue
    * @Column(type="integer")
    */
   private $id;
   /**
     * @Column(type="string")
     */
   private $nome;

   public function getId(): int
   {
      return $this->id;
   }  

   public function getNome(): string
   {
      return $this->nome;
   }

   public function setNome(string $nome): self
   {
      $this->nome = $nome;
      return $this;
   }
}

Estou usando o PHP 7.4.9 e o Mysql 5.7.31

2 respostas
solução!

Fala, Guilherme. O erro é bem claro:

An exception occurred in driver: could not find driver

Você não habilitou o driver pdo_mysql.

:-)

Obrigado! ;-)

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software