EntityManagerFactury.php
<?php
namespace php\Doctrine\Helper;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\Setup;
class EntityManagerFactury{
public function getEntityManager(){
$rootDir = __DIR__ . "/../..";
$config = Setup::createAnnotationMetadataConfiguration([$rootDir . "/src"],true);
$conexao = ["driver"=>"pdo_sqlite","path"=>$rootDir."/var/data/banco.sqlite"];
return EntityManager::create($conexao,$config);
}
}
?>
erro
PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1 no such table: Aluno in C:\Users\pheli\OneDrive\Documentos\php\Doctrine\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:132 Stack trace:
#0 C:\Users\pheli\OneDrive\Documentos\php\Doctrine\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php(132): PDO->query('SELECT t0.id AS...')
#1 C:\Users\pheli\OneDrive\Documentos\php\Doctrine\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOQueryImplementation.php(36): Doctrine\DBAL\Driver\PDOConnection->doQuery('SELECT t0.id AS...')
#2 C:\Users\pheli\OneDrive\Documentos\php\Doctrine\vendor\doctrine\dbal\lib\Doctrine\DBAL\Connection.php(1295): Doctrine\DBAL\Driver\PDOConnection->query('SELECT t0.id AS...')
#3 C:\Users\pheli\OneDrive\Documentos\php\Doctrine\vendor\doctrine\orm\lib\Doctrine\ORM\Persisters\Entity\BasicEntityPersister.php(896): Doctrine\DBAL\Connection->executeQuery('SELECT t0.id AS...', Array, Array)
#4 C:\Users\pheli\OneDrive\Documentos\php\Doctrine\vendor\doctrine\orm\lib\Do in C:\Users\pheli\OneDrive\Documentos\php\Doctrine\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\AbstractSQLiteDriver.php on line 59
Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1 no such table: Aluno in C:\Users\pheli\OneDrive\Documentos\php\Doctrine\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:132 Stack trace:
#0 C:\Users\pheli\OneDrive\Documentos\php\Doctrine\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php(132): PDO->query('SELECT t0.id AS...')
#1 C:\Users\pheli\OneDrive\Documentos\php\Doctrine\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOQueryImplementation.php(36): Doctrine\DBAL\Driver\PDOConnection->doQuery('SELECT t0.id AS...')
#2 C:\Users\pheli\OneDrive\Documentos\php\Doctrine\vendor\doctrine\dbal\lib\Doctrine\DBAL\Connection.php(1295): Doctrine\DBAL\Driver\PDOConnection->query('SELECT t0.id AS...')
#3 C:\Users\pheli\OneDrive\Documentos\php\Doctrine\vendor\doctrine\orm\lib\Doctrine\ORM\Persisters\Entity\BasicEntityPersister.php(896): Doctrine\DBAL\Connection->executeQuery('SELECT t0.id AS...', Array, Array)
#4 C:\Users\pheli\OneDrive\Documentos\php\Doctrine\vendor\doctrine\orm\lib\Do in C:\Users\pheli\OneDrive\Documentos\php\Doctrine\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\AbstractSQLiteDriver.php on line 59
minha ultima migration
<?php
declare(strict_types=1);
namespace php\Doctrine\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210722180943 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE Aluno (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nome VARCHAR(255) NOT NULL)');
$this->addSql('CREATE TABLE Curso (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nome VARCHAR(255) NOT NULL)');
$this->addSql('CREATE TABLE curso_aluno (curso_id INTEGER NOT NULL, aluno_id INTEGER NOT NULL, PRIMARY KEY(curso_id, aluno_id))');
$this->addSql('CREATE INDEX IDX_6F96721A87CB4A1F ON curso_aluno (curso_id)');
$this->addSql('CREATE INDEX IDX_6F96721AB2DDF7F4 ON curso_aluno (aluno_id)');
$this->addSql('CREATE TABLE Telefone (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, aluno_id INTEGER DEFAULT NULL, numero VARCHAR(255) NOT NULL)');
$this->addSql('CREATE INDEX IDX_D8448137B2DDF7F4 ON Telefone (aluno_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE Aluno');
$this->addSql('DROP TABLE Curso');
$this->addSql('DROP TABLE curso_aluno');
$this->addSql('DROP TABLE Telefone');
}
}