1

因为 APC 中的一个错误,我不得不使用另一个缓存驱动器。我删除了 APC 并安装了 xcache。config.php 说你的配置看起来很适合运行 Symfony

我应要求收到以下错误:

PHP Fatal error:  Uncaught exception 'RuntimeException' with message 'Unable to use ApcClassLoader as APC is not enabled.' in /var/.../app/bootstrap.php.cache:1039
Stack trace:
#0 /var/.../web/app.php(11): Symfony\\Component\\ClassLoader\\ApcClassLoader->__construct('sf2', Object(Composer\\Autoload\\ClassLoader))
#1 {main}
thrown in /var/...app/bootstrap.php.cache on line 1039

我如何告诉 Symfony 使用 xcache 而不是 APC?

4

3 回答 3

3

有同样的问题,我是这样做的:

在第 12 行替换

$loader = new ApcClassLoader('sf2', $loader);

$loader = new XcacheClassLoader('sf2', $loader);

(并定义正确的使用声明)

于 2013-06-07T14:13:50.790 回答
0

替换并添加后$loader = new ApcClassLoader('tcs_beta_prod', $loader);$loader = new XcacheClassLoader('tcs_beta_prod', $loader);use Symfony\Component\ClassLoader\XcacheClassLoader;这个错误Fatal error: Class 'Symfony\Component\ClassLoader\XcacheClassLoader' not found in C:\xampp\htdocs\edt\web\app.php on line 11。这是我的 app.php

<?php

use Symfony\Component\ClassLoader\XcacheClassLoader;
use Symfony\Component\HttpFoundation\Request;

$loader = require_once __DIR__.'/../app/bootstrap.php.cache';

// Use APC for autoloading to improve performance
// Change 'sf2' by the prefix you want in order to prevent key conflict with another application

$loader = new XcacheClassLoader('tcs_beta_prod', $loader);
$loader->register(true);


require_once __DIR__.'/../app/AppKernel.php';
require_once __DIR__.'/../app/AppCache.php';

$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
$kernel = new AppCache($kernel);
$request = Request::createFromGlobals();
Request::setTrustedProxies(array($request->server->get('REMOTE_ADDR'))); // per suggestion from Farid / Patrick to deal with ELB proxying
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
于 2017-04-07T08:37:25.993 回答
0

您没有为 XCache 定义 use 语句:

use Symfony\Component\ClassLoader\XcacheClassLoader;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\ClassLoader\XcacheClassLoader;
于 2017-11-15T09:13:19.400 回答