Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Erro ao rodar schema-tool:create [3]

Quando executo no terminal o comando vendor\bin\doctrine.bat orm:schema-tool:create utilizando o 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'], true);
        $connection = [
            'driver'=>'pdo_mysql',
            'host' => 'localhost',
            'dbname' => 'doctrine',
            'user' => 'root',
            'password' => 'v22b23g25'
        ];
        return EntityManager::create($connection, $config);
    }
}

recebo no terminal o seguinte:

In ExceptionConverter.php line 119:
  An exception occurred in the driver: could not find driver  


In Exception.php line 26:

  could not find driver  


In Driver.php line 28:

  could not find driver  


orm:schema-tool:create [--em EM] [--dump-sql]

PS C:\Users\victo\Documents\Aulas Alura\Aula PHP\Doctrine> vendor\bin\doctrine.bat orm:schema-tool:create

 !
 ! [CAUTION] This operation should not be executed in a production environment!
 !

 Creating database schema...


In ExceptionConverter.php line 103:

  An exception occurred in the driver: SQLSTATE[HY000] [1049] Unknown database 'doctrine'  


In Exception.php line 26:

  SQLSTATE[HY000] [1049] Unknown database 'doctrine'  


In Driver.php line 28:

  SQLSTATE[HY000] [1049] Unknown database 'doctrine'  


orm:schema-tool:create [--em EM] [--dump-sql]

Vi um tópico de dúvida com o mesmo erro ([https://cursos.alura.com.br/forum/topico-erro-ao-rodar-schema-tool-create-2-192060]), a solução apresentada seria descomentar a linha extension=pdomysql mas não existe essa extensão no meu php.ini. tentei descomentar extension=mysqli e extension=pdo_mysql, mas o erro persiste da mesma forma.

1 resposta
solução!

Encontrei o erro no 'dbname' => 'doctrine', que deveria ser 'dbname' => 'curso_doctrine',.