I have a very strange problem with Doctrine and PHP 5.5.6 Opcache. Everything works fine when the module is opcacheturned off. As soon as I turn it on, I start getting the following exception:
Fatal error: Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'Class "Admin\Models\Users\Role" is not a valid entity or mapped super class.' in vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php on line 336
( ! ) Doctrine\ORM\Mapping\MappingException: Class "Admin\Models\Users\Role" is not a valid entity or mapped super class. in vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php on line 336
Call Stack
1 0.0000 128016 {main}( ) ../app.php:0
2 0.0185 615020 Core\Bootstrap->handle( ) ../app.php:53
3 0.0210 695744 call_user_func_array ( ) ../Bootstrap.php:111
4 0.0210 695976 Admin\Controllers\DashboardController->indexAction( ) ../Bootstrap.php:111
5 0.0210 696028 Doctrine\ORM\EntityManager->getRepository( ) ../DashboardController.php:25
6 0.0210 696072 Doctrine\ORM\Repository\DefaultRepositoryFactory->getRepository( ) ../EntityManager.php:759
7 0.0210 696176 Doctrine\ORM\Repository\DefaultRepositoryFactory->createRepository( ) ../DefaultRepositoryFactory.php:50
8 0.0210 696200 Doctrine\ORM\EntityManager->getClassMetadata( ) ../DefaultRepositoryFactory.php:67
9 0.0210 696420 Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor( ) ../EntityManager.php:295
10 0.0213 699628 Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata( ) ../AbstractClassMetadataFactory.php:211
11 0.0224 781128 Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata( ) ../AbstractClassMetadataFactory.php:318
12 0.0224 782824 Doctrine\ORM\Mapping\Driver\AnnotationDriver->loadMetadataForClass( ) ../ClassMetadataFactory.php:117
I believe that my entities are defined correctly - as I mentioned at the beginning, as soon as I turn off opcache, everything works as expected. To initialize Doctrine, I use this piece of code:
$config = Setup::createAnnotationMetadataConfiguration($this->getEntityPaths(), $this->getInDevelopment(), $this->getProxyPath());
$config->setAutoGenerateProxyClasses(true);
$dbParams = array(
'driver' => 'pdo_pgsql',
'host' => $this->getHost(),
'port' => $this->getPort(),
'user' => $this->getUser(),
'password' => $this->getPass(),
'dbname' => $this->getName()
);
$this->db = EntityManager::create($dbParams, $config);
I also tried this configuration:
$config = new Configuration;
$config->setProxyDir($this->getProxyPath());
$config->setProxyNamespace('DoctrineProxies');
$config->setAutoGenerateProxyClasses(true);
$driverImpl = $config->newDefaultAnnotationDriver($this->getEntityPaths());
$config->setMetadataDriverImpl($driverImpl);
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
$config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
$dbParams = array(
'driver' => 'pdo_pgsql',
'host' => $this->host,
'port' => $this->port,
'user' => $this->user,
'password' => $this->pass,
'dbname' => $this->name
);
$this->db = EntityManager::create($dbParams, $config);
Here is the essence
class Role
{
private $role_id;
private $name;
}
AutoGenerateProxyClasses, , , . , . , . ? opcache Doctrine ? - ?