【发布时间】:2010-09-06 20:54:07
【问题描述】:
我在将 Classloader 添加到 Doctrine 2 项目时遇到了一点问题。 我有这样的简单目录结构:
- 配置(引导文件)
- html(带有模板/图像/js等的docroot)
- php
- 实体(学说 2 个实体)
- 响应(一些传输对象)
- 服务(处理 api 和业务逻辑 - 类似于 java 中的会话 bean)
每个 php 子目录都属于自己的命名空间(与目录名称相同)。
我想使用前面提到的类加载器来加载这三个不同的包,所以我的引导程序看起来像这样:
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine', $lib );
$classLoader->register();
$responsesCL = new \Doctrine\Common\ClassLoader('Responses', __DIR__.'/../php');
$responsesCL->register();
$entitiesCL = new \Doctrine\Common\ClassLoader('Entities', __DIR__.'/../php');
$entitiesCL->register();
$servicesCL = new \Doctrine\Common\ClassLoader('Services', __DIR__.'/../php');
$servicesCL->register();
Bold DIR 实际上是__ DIR __ php 常量。
现在,我在我的服务包中指的是实体,这就是问题开始的地方,由于某种原因,由于找不到文件问题,我得到了错误,例如:
需要打开失败 '/var/www/projects/PlatformManagement/config/../php/Services/Entities/User.php' (include_path='.:/usr/share/pear:/usr/share/php') 在 /usr/share/pear/Doctrine/Common/ClassLoader.php 上线 148
不知何故,路径中有额外的“服务”,显然它不是有效路径。我有点纳闷,为什么会有那个额外的目录?我三次检查了所有的命名空间、调用,它们都没有问题。
我需要另一双眼睛才能看到,我假设我在这里遗漏了一些明显的东西,但无法发现它:|
哦,如果有帮助的话,这是 Fedora 上最新的 Doctrine 2 Beta (4) 和 php 5.3.3。
谢谢, 格雷格
【问题讨论】:
-
问题是当我尝试使用包中的类时。我使用的是 Entities\ClassName.class 而不是 \Entities\ClassName.class
标签: php orm classloader doctrine doctrine-orm