Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7684057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:56:18+00:00 2026-05-31T18:56:18+00:00

I’m trying to generate entity repositories and getting such message No Metadata Classes to

  • 0

I’m trying to generate entity repositories and getting such message

No Metadata Classes to process

I’d tracked down that use of

use Doctrine\ORM\Mapping as ORM;
and
@ORM\Table
is not working properly.

If i change all @ORM\Table to just @Table(and other annotations) – it start to work, but I really don’t want to get it that way as it should work with @ORM annotation.

I followed instructions from page below with no luck. I know I’m close but missing something with file paths or namespaces. Please help.

http://docs.doctrine-project.org/projects/doctrine-common/en/latest/reference/annotations.html

Does anyone had such problem? What I missing?

cli-config,

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;

require_once 'Doctrine/Common/ClassLoader.php';

define('APPLICATION_ENV', "development");
error_reporting(E_ALL);



//AnnotationRegistry::registerFile("Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php");
//AnnotationRegistry::registerAutoloadNamespace("Symfony\Component\Validator\Constraint", "Doctrine/Symfony");
//AnnotationRegistry::registerAutoloadNamespace("Annotations", "/Users/ivv/workspaceShipipal/shipipal/codebase/application/persistent/");

$classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
$classLoader->register();

$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__ . '/application/');
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__ . '/application/persistent');
$classLoader->register();

$config = new \Doctrine\ORM\Configuration();
$config->setProxyDir(__DIR__ . '/application/persistent/Proxies');
$config->setProxyNamespace('Proxies');

$config->setAutoGenerateProxyClasses((APPLICATION_ENV == "development"));


$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__ . "/application/persistent/Entities"));
$config->setMetadataDriverImpl($driverImpl);

if (APPLICATION_ENV == "development") {
    $cache = new \Doctrine\Common\Cache\ArrayCache();
} else {
    $cache = new \Doctrine\Common\Cache\ApcCache();
}

$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);


$connectionOptions = array(
    'driver'   => 'pdo_mysql',
    'host'     => '127.0.0.1',
    'dbname'   => 'mydb',
    'user'     => 'root',
    'password' => ''

);

$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
$platform = $em->getConnection()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');

$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
     'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
     'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
));

User.php(working version, initially it was as described, @Table was @ORM\Table and other annotations similar had @ORM\ part like @ORM\Column etc)

<?php
namespace Entities;


use Doctrine\Mapping as ORM;

/**
 * User
 *
 * @Table(name="user")
 * @Entity(repositoryClass="Repository\User")
 */
class User
{
    /**
     * @var integer $id
     *
     * @Column(name="id", type="integer", nullable=false)
     * @Id
     * @GeneratedValue
     */
    private $id;

    /**
     * @var string $userName
     *
     * @Column(name="userName", type="string", length=45, nullable=false)
     */
    private $userName;

    /**
     * @var string $email
     *
     * @Column(name="email", type="string", length=45, nullable=false)
     */
    private $email;

    /**
     * @var text $bio
     *
     * @Column(name="bio", type="text", nullable=true)
     */
    private $bio;

    public function __construct()
    {

    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:56:19+00:00Added an answer on May 31, 2026 at 6:56 pm

    EDIT 3:

    If it matters, I’m using Doctrine 2.2.1. Anyway, I’m just adding a bit more information on this topic.

    I dug around the Doctrine\Configuration.php class to see how newDefaultAnnotationDriver created the AnnotationDriver. The method begins on line 125, but the relevant part is line 145 to 147 if you’re using the latest version of the Common library.

    } else {
        $reader = new AnnotationReader();
        $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
    }
    

    I couldn’t actually find the setDefaultAnnotationNamespace method in AnnotationReader class. So that was weird. But I’m assuming it sets the namespace Doctrine\Orm\Mapping, so that annotations in that namespace don’t need to be prefixed. Hence the error since it seems the doctrine cli tool generates the entities differently. I’m not sure why that is.

    You’ll notice in my answer below, I didn’t call the setDefaultAnnotationNamespace method.

    One a side note, I noticed in your User Entity class that you have use Doctrine\Mapping as ORM. Shouldn’t the generated file create use Doctrine\Orm\Mapping as ORM;? Or maybe that is a typo.

    EDIT 1:
    Ok, I found the problem. Apparently it has to do with the default annotation driver used by the \Doctrine\ORM\Configuration class.

    So instead of using $config->newDefaultAnnotationDriver(...), you need to instantiate a new AnnotationReader, a new AnnotationDriver, and then set it in your Configuration class.

    Example:

    AnnotationRegistry::registerFile("Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php");
    $reader = new AnnotationReader();
    $driverImpl = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, array(__DIR__ . "/application/persistent/Entities"));
    $config->setMetadataDriverImpl($driverImpl);
    

    EDIT2 (Here the adjustments added to your cli-config.php):

    use Doctrine\Common\Annotations\AnnotationReader;
    use Doctrine\Common\Annotations\AnnotationRegistry;
    
    require_once 'Doctrine/Common/ClassLoader.php';
    
    define('APPLICATION_ENV', "development");
    error_reporting(E_ALL);
    
    $classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
    $classLoader->register();
    
    $classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__ . '/application/');
    $classLoader->register();
    $classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__ . '/application/persistent');
    $classLoader->register();
    
    $config = new \Doctrine\ORM\Configuration();
    $config->setProxyDir(__DIR__ . '/application/persistent/Proxies');
    $config->setProxyNamespace('Proxies');
    
    $config->setAutoGenerateProxyClasses((APPLICATION_ENV == "development"));
    
    
     //Here is the part that needs to be adjusted to make allow the ORM namespace in the annotation be recognized
    
    #$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__ . "/application/persistent/Entities"));
    
    AnnotationRegistry::registerFile("Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php");
    $reader = new AnnotationReader();
    $driverImpl = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, array(__DIR__ . "/application/persistent/Entities"));
    $config->setMetadataDriverImpl($driverImpl);
    
    //End of Changes
    
    if (APPLICATION_ENV == "development") {
        $cache = new \Doctrine\Common\Cache\ArrayCache();
    } else {
       $cache = new \Doctrine\Common\Cache\ApcCache();
    }
    
    $config->setMetadataCacheImpl($cache);
    $config->setQueryCacheImpl($cache);
    
    
    $connectionOptions = array(
        'driver'   => 'pdo_mysql',
        'host'     => '127.0.0.1',
        'dbname'   => 'mydb',
        'user'     => 'root',
        'password' => ''
    );
    
    $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
    $platform = $em->getConnection()->getDatabasePlatform();
    $platform->registerDoctrineTypeMapping('enum', 'string');
    
    $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
        'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
        'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
    ));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.