【问题标题】:Unable to use ClassLoader in Doctrine. No such file or directory无法在 Doctrine 中使用 ClassLoader。无此文件或目录
【发布时间】:2013-07-28 14:48:36
【问题描述】:

我正在尝试在 linux 服务器上使用 Doctrine,但发现它很难开始。

我有以下文件夹结构

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

init.php的内容:

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

Template 类分别位于 Entities 命名空间中:

<?php
namespace Entities;

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

但是,当类加载器尝试注册类时,一切都会出错:

[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或 /var/www/vendor/doctrine/common/lib/Doctrine/Common/ClassLoader.php 第 164 行中的目录

[2013 年 7 月 28 日星期日 21:59:30] [错误] [客户端 192.168.1.225] PHP 致命错误:require():无法打开所需的“/var/www/database/Entities/Template.php”(include_path ='.:/usr/share/php:/usr/share/pear') 在 /var/www/vendor/doctrine/common/lib/Doctrine/Common/ClassLoader.php 第 164 行

[Sun Jul 28 21:59:36 2013] [error] [client 192.168.1.225] 文件不存在:/var/www/favicon.ico

这是我第一次使用Doctrine,目前情况下调试困难。非常感谢您的建议。

我在 Windows 上的设置完全相同,唯一的区别是调用:

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

一切正常。

【问题讨论】:

    标签: php doctrine-orm


    【解决方案1】:

    命名空间实体;

    应该是小写

    命名空间实体;

    然后它在 Linux 中运行良好。

    【讨论】:

      猜你喜欢
      • 2020-08-07
      • 2021-12-26
      • 2012-11-08
      • 2021-03-28
      • 2020-04-18
      • 2020-07-28
      • 1970-01-01
      相关资源
      最近更新 更多