$em = /* EntityManager instance */; $metadata = $em->getClassMetadata('App\Entity\User');
$em = /* EntityManager instance */; if ($em->getClassMetadata('App\Entity\User')) { // The User entity is managed by Doctrine ORM } else { // The User entity is not managed by Doctrine ORM }In this example, we use getClassMetadata to check whether the User entity class is managed by Doctrine ORM. If the method returns a non-null metadata object, we know that the class is managed by Doctrine ORM and can be used with other parts of the library. Package library: Doctrine ORM (https://github.com/doctrine/orm)