无法包含Zend Cache

时间:2015-04-30 20:04:15

标签: php caching zend-framework

我试图使用Zend Cache。 如文档中所示:http://framework.zend.com/manual/current/en/modules/zend.cache.storage.adapter.html#quick-start

我使用composer加载框架:

{
    "repositories": [
    {
        "type": "composer",
        "url": "https://packages.zendframework.com/"
    }
    ],
    "require": {
    "zendframework/zend-cache": "2.*"
    }

}

我的文件结构是这样的: enter image description here

在档案test.php

我把示例代码放在docs:

<?php


use Zend\Cache\StorageFactory;

// Via factory:
$cache = StorageFactory::factory(array(
    'adapter' => array(
        'name'    => 'apc',
        'options' => array('ttl' => 3600),
    ),
    'plugins' => array(
        'exception_handler' => array('throw_exceptions' => false),
    ),
));

// Alternately:
$cache  = StorageFactory::adapterFactory('apc', array('ttl' => 3600));
$plugin = StorageFactory::pluginFactory('exception_handler', array(
    'throw_exceptions' => false,
));
$cache->addPlugin($plugin);

// Or manually:
$cache  = new Zend\Cache\Storage\Adapter\Apc();
$cache->getOptions()->setTtl(3600);

$plugin = new Zend\Cache\Storage\Plugin\ExceptionHandler();
$plugin->getOptions()->setThrowExceptions(false);
$cache->addPlugin($plugin);

但是当我进入页面时,我收到了这个错误:

Fatal error: Class 'Zend\Cache\StorageFactory' not found in /var/www/libs/cache/vendor/test.php on line 7

我也尝试过使用:

include_once 'autoload.php';

但我得到了同样的错误。

0 个答案:

没有答案