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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:22:01+00:00 2026-05-18T21:22:01+00:00

I’m using Kohana 3 and have a /doctrine/Entites folder with my entities inside. When

  • 0

I’m using Kohana 3 and have a /doctrine/Entites folder with my entities inside. When executing the code

$product = Doctrine::em()->find('Entities\Product', 1);

in my controller, I get the error

class_parents(): Class Entities\Product does not exist and could not be loaded

Below is the Controller (classes/controller/welcome.php):

<?php

class Controller_Welcome extends Controller {

    public function action_index()
    {
        $prod = Doctrine::em()->find('Entities\Product', 1);
    }

}

Below is the Entity (/doctrine/Entities/Product.php):

<?php

/**
 * @Entity
 * @Table{name="products"}
 */
class Product
{
    /** @Id @Column{type="integer"} */
    private $id;
    /** @Column(type="string", length="255") */
    private $name;

    public function getId() { return $this->id; }
    public function setId($id) { $this->id = intval($id); }
    public function getName() { return $this->name; }
    public function setName($name) { $this->name = $name; }
}

Below is the Doctrine module bootstrap file (/modules/doctrine/init.php):

class Doctrine
{
    private static $_instance = null;
    private $_application_mode = 'development';
    private $_em = null;

    public static function em()
    {
        if ( self::$_instance === null )
            self::$_instance = new Doctrine();

        return self::$_instance->_em;
    }

    public function __construct()
    {
        require __DIR__.'/classes/doctrine/Doctrine/Common/ClassLoader.php';

        $classLoader = new \Doctrine\Common\ClassLoader('Doctrine', __DIR__.'/classes/doctrine');
        $classLoader->register();
        $classLoader = new \Doctrine\Common\ClassLoader('Symfony', __DIR__.'/classes/doctrine/Doctrine');
        $classLoader->register();
        $classLoader = new \Doctrine\Common\ClassLoader('Entities', APPPATH.'doctrine');
        $classLoader->register();

        //Set up caching method
        $cache = $this->_application_mode == 'development'
            ? new \Doctrine\Common\Cache\ArrayCache
            : new \Doctrine\Common\Cache\ApcCache;

        $config = new Configuration;
        $config->setMetadataCacheImpl( $cache );
        $driver = $config->newDefaultAnnotationDriver( APPPATH.'doctrine/Entities' );
        $config->setMetadataDriverImpl( $driver );
        $config->setQueryCacheImpl( $cache );

        $config->setProxyDir( APPPATH.'doctrine/Proxies' );
        $config->setProxyNamespace('Proxies');
        $config->setAutoGenerateProxyClasses( $this->_application_mode == 'development' );

        $dbconf = Kohana::config('database');
        $dbconf = reset($dbconf); //Use the first database specified in the config

        $this->_em = EntityManager::create(array(
            'dbname'     => $dbconf['connection']['database'],
            'user'         => $dbconf['connection']['username'],
            'password'     => $dbconf['connection']['password'],
            'host'         => $dbconf['connection']['hostname'],
            'driver'     => 'pdo_mysql',
        ), $config);
    }
}

Any ideas what I’ve done wrong?

  • 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-18T21:22:01+00:00Added an answer on May 18, 2026 at 9:22 pm

    UPDATE: namespace Entities; has to be in the beginning of every Entity

    It’s something with the autoloader. I’m very new to Doctrine 2 (even new to 1.2) but I think it’s in your:

        $classLoader = new \Doctrine\Common\ClassLoader('Entities', APPPATH.'doctrine');
        $classLoader->register();
    

    Try adding a realpath(APPPATH.’doctrine’). I use Zend Framework so it looks a little different in the bootstrap but maybe it’ll help:

    /**
     * Initialize auto loader of Doctrine
     *
     * @return Doctrine_Manager
     */
    protected function _initDoctrine() {
        $this->bootstrap('autoload');
    
        require_once('Doctrine/Common/ClassLoader.php');
    
        /*
          $classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
          $classLoader->setIncludePath(APPLICATION_PATH . '/../library/');
          $classLoader->register();/* */
    
        // Create the doctrine autoloader and remove it from the spl autoload stack (it adds itself)
        require_once 'Doctrine/Common/ClassLoader.php';
        $doctrineAutoloader = array(new \Doctrine\Common\ClassLoader(), 'loadClass');
        //$doctrineAutoloader->register();
        spl_autoload_unregister($doctrineAutoloader);
    
        $autoloader = Zend_Loader_Autoloader::getInstance();
    
        // Push the doctrine autoloader to load for the Doctrine\ namespace
        $autoloader->pushAutoloader($doctrineAutoloader, 'Doctrine');
    
        $classLoader = new \Doctrine\Common\ClassLoader('Entities', realpath(__DIR__ . '/models/'), 'loadClass');
        $autoloader->pushAutoloader(array($classLoader, 'loadClass'), 'Entities');
    
        $classLoader = new \Doctrine\Common\ClassLoader('Symfony', realpath(__DIR__ . '/../library/Doctrine/'), 'loadClass');
        $autoloader->pushAutoloader(array($classLoader, 'loadClass'), 'Symfony');
    
        $doctrineConfig = $this->getOption('doctrine');
        $config = new \Doctrine\ORM\Configuration();
    
        $cache = new \Doctrine\Common\Cache\ArrayCache;
        $config->setMetadataCacheImpl($cache);
        $config->setQueryCacheImpl($cache);
    
        $driverImpl = new Doctrine\ORM\Mapping\Driver\YamlDriver(APPLICATION_PATH . '/configs/mappings/yaml');
        //$driverImpl = $config->newDefaultAnnotationDriver($doctrineConfig['path']['entities']);
        $config->setMetadataDriverImpl($driverImpl);
    
        //$driverImpl = $config->newDefaultAnnotationDriver(
        //       array($doctrineConfig['paths']['entities']));
        //$config->setMetadataDriverImpl($driverImpl);
    
        $config->setProxyDir(APPLICATION_PATH . '/../proxies');
        $config->setProxyNamespace('App\Proxies');
    
        $connectionOptions = array(
            'driver' => $doctrineConfig['conn']['driv'],
            'user' => $doctrineConfig['conn']['user'],
            'password' => $doctrineConfig['conn']['pass'],
            'dbname' => $doctrineConfig['conn']['dbname'],
            'host' => $doctrineConfig['conn']['host']
        );
    
    
        $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
    
        $eventManager = $em->getEventManager();
        $eventManager->addEventSubscriber(new Maxlib_EventSubscriber_Sortable());
    
        $registry = Zend_Registry::getInstance();
        $registry->entitymanager = $em;
    
    
        return $em;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code to decode numeric html entities to the UTF8 equivalent character.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the

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.