简体   繁体   中英

Unable to use ClassLoader in Doctrine. No such file or directory

I am trying to use Doctrine on a linux server and am finding it difficult to start with.

I have the following folder structure

/var/www
init.php
/database
    /entities
        Template.php

The contents of init.php:

<?php
$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__."/database");
$classLoader->register();
?>

Respectively the Template class is in the Entities namespace:

<?php
namespace Entities;

/** @Entity **/
class Template {
    ...
}
?>

When the class loader tries to register the classes, however, it all errors out:

[Sun Jul 28 21:59:30 2013] [error] [client 192.168.1.225] PHP Warning: require(/var/www/database/Entities/Template.php): failed to open stream: No such file or directory in /var/www/vendor/doctrine/common/lib/Doctrine/Common/ClassLoader.php on line 164

[Sun Jul 28 21:59:30 2013] [error] [client 192.168.1.225] PHP Fatal error: require(): Failed opening required '/var/www/database/Entities/Template.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/vendor/doctrine/common/lib/Doctrine/Common/ClassLoader.php on line 164

[Sun Jul 28 21:59:36 2013] [error] [client 192.168.1.225] File does not exist: /var/www/favicon.ico

This is the first time I am using Doctrine and the difficulty is in debugging in the current situation. I would be thankful for your suggestions.

I have the exact same setup on Windows with the only difference being to the call:

    $classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__."//database//");

where it all works fine.

namespace Entities;

should be lower case

namespace entities;

and then it works fine in Linux.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM