Search code examples
classdoctrinexamppundefineddbal

Undefined class and method using Doctrine


I've been brought into a project and trying to duplicate the project locally. I have XAMPP set up on my machine, but I'm having a difficult time getting the path right. On the server the set up has the Doctrine library above the public_html folder. I've done the same on my local machine, but it seems that the call is not finding the right place.

The previous developer has

    function __autoload($class_name)
{
    require str_replace("\\", "/", $class_name) . '.php';
}

Now, everywhere in phpstorm, I find the class not defined or method not defined for Doctrine\DBAL\Configuration...

Example Configuration says Undefined Class:

$config = new Doctrine\DBAL\Configuration();

or this Undefined Class again

$this->connection = Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);

Any help would be much appreciated. I haven't developed with Doctrine before. I'm thinking it could be how my hierarchy is set up somehow, but it mirrors the remote host.


Solution

  • The path was indeed wrong on my localhost setup. I needed to add the resource files in phpStorm so that the project could access those files; plus, the path to Doctrine was higher up.