无法访问Zend Framework 2上的供应商文件和命名空间

时间:2013-08-13 14:42:42

标签: php zend-framework2

我需要从供应商文件夹中获取我的库,但我无法从我的控制器实例化它。每当我尝试调用类名时,它都不起作用并始终导致

致命错误:第33行的/var/www/project1/module/Sportsui/src/Sportsui/Controller/DropboxController.php中找不到“Sports \ Database \ Model \ DropboxMapper”类

我的供应商目录看起来像

vendor/
├── autoload.php
├── bin
│   ├── autoload_classmap.php
│   ├── classmap_generator.php -> ../zendframework/zendframework/bin/classmap_generator.php
│   ├── plugin_classmap.php
│   ├── pluginmap_generator.php -> ../zendframework/zendframework/bin/pluginmap_generator.php
│   └── templatemap_generator.php -> ../zendframework/zendframework/bin/templatemap_generator.php
├── composer
│   ├── autoload_classmap.php
│   ├── autoload_namespaces.php
│   ├── autoload_real.php
│   ├── ClassLoader.php
│   └── installed.json
├── mwGearman
├── README.md
├── Sports
│   ├── autoload_classmap.php
│   ├── library
│   │   └── Sports
│   │       ├── Database
│   │       │   └── Model
│   │       │       ├── DropboxMapper.php
│   │       │       ├── Entity
│   │       │       │   ├── Dropbox.php
│   │       │       │   ├── EntityAbstract.php
│   │       │       │   ├── SourceFields.php
│   │       │       │   └── Sources.php
│   │       │       ├── MapperAbstract.php
│   │       │       ├── SourceFieldsMapper.php
│   │       │       └── SourcesMapper.php
│   │       ├── FileSystemHandler.php
│   │       ├── Gearman
│   │       │   ├── Client.php
│   │       │   ├── DropboxClient.php
│   │       │   ├── DropboxWorker.php
│   │       │   ├── ValidatorClient.php
│   │       │   ├── ValidatorWorker.php
│   │       │   └── Worker.php
│   │       ├── Mvc
│   │       │   └── Controller
│   │       │       └── UtilsController.php
│   │       └── Utility
│   │           └── FileReader.php
│   └── Module.php
└── ZF2

ZF2生成的自动加载类映射器看起来像这样

<?php
// Generated by ZF2's ./bin/classmap_generator.php
return array(
    'Sports\Module'                               => __DIR__ . '/Module.php',
    'Sports\FileSystemHandler'                    => __DIR__ . '/library/Sports/FileSystemHandler.php',
    'Sports\Database\Model\DropboxMapper'         => __DIR__ . '/library/Sports/Database/Model/DropboxMapper.php',
    'Sports\Database\Model\SourcesMapper'         => __DIR__ . '/library/Sports/Database/Model/SourcesMapper.php',
    'Sports\Database\Model\SourceFieldsMapper'    => __DIR__ . '/library/Sports/Database/Model/SourceFieldsMapper.php',
    'Sports\Database\Model\Entity\Dropbox'        => __DIR__ . '/library/Sports/Database/Model/Entity/Dropbox.php',
    'Sports\Database\Model\Entity\EntityAbstract' => __DIR__ . '/library/Sports/Database/Model/Entity/EntityAbstract.php',
    'Sports\Database\Model\Entity\SourceFields'   => __DIR__ . '/library/Sports/Database/Model/Entity/SourceFields.php',
    'Sports\Database\Model\Entity\Sources'        => __DIR__ . '/library/Sports/Database/Model/Entity/Sources.php',
    'Sports\Database\Model\MapperAbstract'        => __DIR__ . '/library/Sports/Database/Model/MapperAbstract.php',
    'Sports\Mvc\Controller\UtilsController'       => __DIR__ . '/library/Sports/Mvc/Controller/UtilsController.php',
    'Sports\Gearman\ValidatorWorker'              => __DIR__ . '/library/Sports/Gearman/ValidatorWorker.php',
    'Sports\Gearman\ValidatorClient'              => __DIR__ . '/library/Sports/Gearman/ValidatorClient.php',
    'Sports\Gearman\Worker'                       => __DIR__ . '/library/Sports/Gearman/Worker.php',
    'Sports\Gearman\DropboxWorker'                => __DIR__ . '/library/Sports/Gearman/DropboxWorker.php',
    'Sports\Gearman\Client'                       => __DIR__ . '/library/Sports/Gearman/Client.php',
    'Sports\Gearman\DropboxClient'                => __DIR__ . '/library/Sports/Gearman/DropboxClient.php',
    'Sports\Utility\FileReader'                   => __DIR__ . '/library/Sports/Utility/FileReader.php',
);

主配置

    // These are various options for the listeners attached to the ModuleManager
'module_listener_options' => array(
    // This should be an array of paths in which modules reside.
    // If a string key is provided, the listener will consider that a module
    // namespace, the value of that key the specific path to that module's
    // Module class.
    'module_paths' => array(
        './module',
        './vendor',
    ),

和控制器

namespace SportsUi\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Sports\Database\Model\DropboxMapper;


class DropboxController extends AbstractActionController
{
    public function fooAction()
    {
        // echo "Asdasd";
       return array();     
    }

    public function indexAction()
    {
        // echo "Asdasd";
       return array();     
    }

    public function viewFileAction()
    {
        $dropbox = new DropboxMapper(); //
        return array('title'=> 'Title of the page');
    }


}

0 个答案:

没有答案