Olá, estou com esta exeption: Já comentei as configurações no php.ini: extension_dir = "ext" E o pdo como está mostrado abaixo:
Estou mandando os arquivos e uma demonstração do diretório.
PS D:\PUCPR\Fundamentos_programação_web_1\PHP\PHP_1\2612-doctrine> php bin/doctrine.php orm:schema-tool:create
!
! [CAUTION] This operation should not be executed in a production environment!
!
Creating database schema...
In ToolsException.php line 19:
Schema-Tool failed with Error 'An exception occurred in the driver: could not find driver' while executing DDL: CR
EATE TABLE Student (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name VARCHAR(255) NOT NULL)
In ExceptionConverter.php line 83:
An exception occurred in the driver: could not find driver
In Exception.php line 28:
could not find driver
In Driver.php line 39:
could not find driver
orm:schema-tool:create [--em EM] [--dump-sql]
extensions habilitadas:
;extension=bz2
extension=curl
;extension=ffi
;extension=ftp
extension=fileinfo
;extension=gd
;extension=gettext
;extension=gmp
;extension=intl
;extension=imap
;extension=ldap
;extension=mbstring
;extension=exif ; Must be after mbstring as it depends on it
extension=mysqli
;extension=oci8_12c ; Use with Oracle Database 12c Instant Client
;extension=oci8_19 ; Use with Oracle Database 19 Instant Client
;extension=odbc
;extension=openssl
;extension=pdo_firebird
extension=pdo_mysql
;extension=pdo_oci
;extension=pdo_odbc
extension=pdo_pgsql
extension=pdo_sqlite
;extension=pgsql
;extension=shmop
EntityManagerCreator
<?php
namespace Alura\Doctrine\Helper;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\ORMSetup;
class EntityManagerCreator
{
// classe para estabelecer a conexão com o banco de dados
public static function createEntityManager() :EntityManager
{
// Create a simple "default" Doctrine ORM configuration for Attributes
$config = ORMSetup::createAttributeMetadataConfiguration(
[__DIR__."/.."], // tudo aqui pode ser mapeado pelo doctrine | volta uma pasta
true);
// database configuration parameters // aqui seria feita a conexao do postgresql
$conn = [
'driver' => 'pdo_sqlite',
'path' => __DIR__ . '/../../db.sqlite',
];
// obtaining the entity manager
return EntityManager::create($conn, $config);
}
}
Student
<?php
namespace Alura\Doctrine\Entity;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
#[Entity]
class Student
{
#[Id]
#[GeneratedValue]
#[Column]
public readonly int $id;
// Já cria os atributos e seus objetos
public function __construct(
#[Column]
public readonly string $name
)
{
}
}
cli-config.php
<?php
use Doctrine\ORM\Tools\Console\ConsoleRunner;
// replace with file to your own project bootstrap
require_once 'vendor/autoload.php';
// replace with mechanism to retrieve EntityManager in your app
$entityManager = \Alura\Doctrine\Helper\EntityManagerCreator::createEntityManager();
return ConsoleRunner::createHelperSet($entityManager);
composer.json
{
"require": {
"doctrine/orm": "^2.11.0",
"doctrine/dbal": "^3.2",
"symfony/yaml": "^5.4",
"symfony/cache": "^5.4"
},
"autoload": {
"psr-4": {
"Alura\\Doctrine\\": "src/"
}
}
}
doctrine.php
<?php
// bin/doctrine
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider;
// Adjust this path to your actual bootstrap.php
require __DIR__ . '/../vendor/autoload.php';
$entityManager = \Alura\Doctrine\Helper\EntityManagerCreator::createEntityManager();
ConsoleRunner::run(
new SingleManagerProvider($entityManager)
);
esquema