Php 找不到Zend framework 2 Zend\config

Php 找不到Zend framework 2 Zend\config,php,zend-framework2,Php,Zend Framework2,当我尝试使用以下方法创建xml文档时,Zf2出现问题: $config = new Zend\Config\Config(array(), true); 我遵循以下官方文件: 我确信zf2是加载器,我不知道那里发生了什么,但是 我的输出是 Fatal error: Class 'XmlGenerator\Controller\Zend\Config\Config' not found in C:\wamp\www\myLink\module\XmlGenerator\src\XmlGener

当我尝试使用以下方法创建xml文档时,Zf2出现问题:

$config = new Zend\Config\Config(array(), true);
我遵循以下官方文件:

我确信zf2是加载器,我不知道那里发生了什么,但是

我的输出是

Fatal error: Class 'XmlGenerator\Controller\Zend\Config\Config' not found in C:\wamp\www\myLink\module\XmlGenerator\src\XmlGenerator\Controller\XmlGeneratorController.php
如果有人能解释,我迷路了p


提前谢谢

您有名称空间问题

您需要将Zend名称空间包含在
use Zend中
在声明名称空间后,或将代码更改为
$config=new\Zend\config\config(array(),true)

PHP正在当前名称空间中查找类,因此它添加当前名称空间以填充类的名称(在本例中为“XmlGenerator\Controller”),自动加载程序使用该名称确定从哪个目录获取类。由于Zend代码与控制器不在同一目录中,自动加载程序将阻塞并向您提供错误信息

您需要告诉您的代码您也在使用Zend名称空间(通过
use
),或者您正在使用的类在全局名称空间中(在类名称前面加上
\