Entities not detected with aliased namespace imports. #8621
-
The entity class (generated mostly by DQL plugin of PhpStorm): <?php
namespace Company\Project\DoctrineEntity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="Company\Project\DoctrineRepository\ContactUsFormSubmissionRepository")
*/
class ContactUsFormSubmission
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue
*/
private $id;
/**
* @var string
* @ORM\Column(type="string", length=30)
*/
private $firstName;
/**
* @var string
* @ORM\Column(type="string", length=30)
*/
private $lastName;
} Here is how Doctrine ORM is initiated: // Configure database.
$db_params = array(
'driver' => 'pdo_mysql',
'host' => $_SERVER['DB_HOST'],
'dbname' => $_SERVER['DB_NAME'],
'user' => $_SERVER['DB_USER'],
'password' => $_SERVER['DB_PASSWORD'],
);
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . '/src/DoctrineEntity'), false);
$config->addEntityNamespace('App', 'Company\Project\DoctrineEntity');
$entity_manager = EntityManager::create($db_params, $config);
$helper_set = ConsoleRunner::createHelperSet($entity_manager); Attempt to use This happens likely due fact, that the simple annotation manager has initialized with a hardcoded P.S. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Yes this is how the simple annotation reader works. I believe this is documented, but don't expect any large changes in this, since with PHP 8 attributes, annotations are sort of reaching their end of life |
Beta Was this translation helpful? Give feedback.
-
Setting |
Beta Was this translation helpful? Give feedback.
Setting
$useSimpleAnnotationReader
argument of\Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration
method tofalse
did the trick. Now all works as expected.