Boa noite! Estou tentando criar paginação mas o doctrine da erro e não é claro, usando php 7.4
erro:
( ! ) Fatal error: Uncaught Doctrine\ORM\Query\QueryException: SELECT e FROM Empresa e in C:\wamp64\www\greenbook\vendor\doctrine\orm\lib\Doctrine\ORM\Query\QueryException.php on line 63
( ! ) Doctrine\ORM\Query\QueryException: [Semantical Error] line 0, col 14 near 'Empresa e': Error: Class 'Empresa' is not defined. in C:\wamp64\www\greenbook\vendor\doctrine\orm\lib\Doctrine\ORM\Query\QueryException.php on line 63
classe empresa:
/** @Entity(repositoryClass="greenbook\repository\EmpresaRepository") */
class Empresa extends Cadastravel
{
/**
* @Id
* @GeneratedValue
* @Column(type="integer")
*/
private int $id;
/** @Column(type="string") */
private string $razaoSocial;
/** @Column(type="string", nullable=true) */
private string $nomeFantasia;
método no repository:
function getAllWithPage(): Paginator
{
$dql = "SELECT e FROM Empresa e";
$query = $this->getEntityManager()->createQuery($dql)
->setFirstResult(0)
->setMaxResults(100);
return new Paginator($query, $fetchJoinCollection = false);
}
Código que executa:
require_once __DIR__ . '/../../../vendor/autoload.php';
$factory = new EntityManagerFactory();
$repository = $factory->getEntityManager()->getRepository(Empresa::class);
$paginator = $repository->getAllWithPage();
foreach ($paginator as $post) {
echo $post->getHeadline() . "\n";
}