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 9024743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:06:04+00:00 2026-06-16T06:06:04+00:00

I just started to use Doctrine2 and I have an error when I want

  • 0

I just started to use Doctrine2 and I have an error when I want to persist an entity. Here is my error: ‘Class “Myapp\app\entity\user” is not a valid entity or mapped super class.’

eAccelerator is not installed on my computer.

My app (I don’t use Symfony) structure is like that:

  • MyApp
    • app
      • entity
    • core
      • external
        • Doctrine

And I initialize Doctrine with:

$classLoader = new ClassLoader('Doctrine', CORE_PATH . 'external');
$classLoader->register();

$cache = new \Doctrine\Common\Cache\ArrayCache();

$doctrineConfig = new \Doctrine\ORM\Configuration();

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

$driverImpl = $doctrineConfig->newDefaultAnnotationDriver(array(APP_PATH . 'entity'));
$doctrineConfig->setMetadataDriverImpl($driverImpl);

$doctrineConfig->setAutoGenerateProxyClasses(false);

$connectionOptions = array(
    'driver'   => $database['driver'],
    'dbname'   => $database['dbname'],
    'user'     => $database['username'],
    'password' => $database['password']
);

$this->em = EntityManager::create($connectionOptions, $doctrineConfig);

What is wrong with these lines ?

Also as I autoload my classes with an autoloader, is it necessary to use the Doctrine class loader ? If yes, are these lines correct ?

$classLoader = new ClassLoader('myApp\app\entity', APP_PATH . 'entity');
$classLoader->register();

$classLoader = new ClassLoader('myApp\core\entity', CORE_PATH . 'entity');
$classLoader->register();

Edit: I forgot to add an entity class

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 */
class user
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;

/**
* @ORM\Column(name="username", type="string", length=255)
*/
protected $username;

/**
* @ORM\Column(name="nicename", type="string", length=255)
*/
protected $nicename;

/**
* @ORM\Column(name="email", type="string", length=255)
*/
protected $email;

/**
* @ORM\Column(name="password", type="string", length=255)
*/
protected $password;

//getters
//setters
  • 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-06-16T06:06:06+00:00Added an answer on June 16, 2026 at 6:06 am

    Ok, so my entity was correct and I don’t need to call classLoader.

    below is the correct initialization:

        $classLoader = new ClassLoader('Doctrine', CORE_PATH . 'external/');
        $classLoader->register();
    
        AnnotationRegistry::registerFile(CORE_PATH.'external/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
    
        $cache = new ArrayCache();
    
        $annotationReader = new AnnotationReader();
    
        $cacheReader = new CachedReader(
            $annotationReader, 
            $cache          
        );
    
        $driverChain = new DriverChain();
    
        $annotationDriver = new AnnotationDriver(
            $annotationReader,
            array(CORE_PATH . 'model/')
        );
    
        $driverChain->addDriver($annotationDriver, 'gallib\core\model');
    
        $doctrineConfig = new Configuration();
    
        $doctrineConfig->setProxyDir(CORE_PATH . 'model/proxy');
        $doctrineConfig->setProxyNamespace('gallib\core\model\proxy');
        $doctrineConfig->setAutoGenerateProxyClasses(true);
        $doctrineConfig->setMetadataDriverImpl($driverChain);
        $doctrineConfig->setMetadataCacheImpl($cache);
        $doctrineConfig->setQueryCacheImpl($cache);
    
        $database = $this->config->database;
    
        $connectionOptions = array(
            'driver'   => $database['driver'],
            'dbname'   => $database['dbname'],
            'user'     => $database['username'],
            'password' => $database['password']
        );
    
        $this->em = EntityManager::create($connectionOptions, $doctrineConfig);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started to use jVectorMap. I want to be able to select
I just started to use Liferay and I want to develop a portlet using
I just started to use doxygen and may not be familiar with all available
I just started to use SQL Server 2008. I have a winforms application that
I have just started to use ServiceStack which is an amazing library. However, I
I have just started to use Eclipse for my Java programmaing. I just wonder
Right now I have just started to use pyparsing to parse simple postfix expressions.
I have a problem that I can't get through. I just started to use
I'm a fairly experienced Java user, but I've just started trying to use NetBeans
I have just started to use the newest version of S#arp Architecture 1.9.5, which

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.