Doctrine stupid or me stupid?

Posted by ropstah on Stack Overflow See other posts from Stack Overflow or by ropstah
Published on 2010-03-30T14:47:01Z Indexed on 2010/03/30 14:53 UTC
Read the original article Hit count: 506

Filed under:
|

I want to use a single Doctrine install on our server and serve multiple websites. Naturally the models should be maintained in the websites' modelsfolder.

I have everything up (and not running) like so:

Doctrine @

/CustomFramework/Doctrine

Websites @

/var/www/vhosts/custom1.com/
/var/www/vhosts/custom2.com/

Generating works fine, all models are delivered in /application_folder/models and /application_folder/models/generated for the correct website.

I've added Doctrine::loadModels('path_to_models') in the bootstrap file for each website, and also registered the autoloaded.

But....

This is the autoloader code:

public static function autoload($className)
{
    if (strpos($className, 'sfYaml') === 0) {
        require dirname(__FILE__) . '/Parser/sfYaml/' . $className . '.php';
        return true;
    }

    if (0 !== stripos($className, 'Doctrine_') || class_exists($className, false) || interface_exists($className, false)) {
        return false;
    }

    $class = self::getPath() . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';

    if (file_exists($class)) {
        require $class;

        return true;
    }

    return false;
 }

Am I stupid, or is the autoloader really doing this:

$class = self::getPath() . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';

or, in other words: Does it require me to have ALL my generated doctrine classes inside the Doctrine app directory? Or in other words, do I need a single Doctrine installation for each website?

I'm getting an error that the BaseXXX class cannot be found. So the autoloading doesn't function correctly. I really hope i'm doing something wrong.. anyone?

© Stack Overflow or respective owner

Related posts about php

Related posts about doctrine