问题描述
我试图使用APC或XCache作为操作码来缓存我的php页面。我正在使用Zend和Doctrine,它与自动装载机有问题。
I am trying to use either APC or XCache as an opcode to cache my php pages. I am using it with Zend and Doctrine and it's having a problem with the autoloader.
如果我尝试使用APC,我得到以下内容:
If I try with APC, I get the following:
Fatal error: spl_autoload() [<a href='function.spl-autoload'>function.spl-autoload</a>]:
Class Doctrine_Event could not be loaded in
C:\\[mydir]\\library\\doctrine\\Doctrine\\Record.php on line 777
如果我尝试使用XCache,我得到以下内容:
If I try with XCache I get the following:
PHP Fatal error: Cannot redeclare class Zend_Registry in
C:\\[mydir]\\library\\zendframework\\Zend\\Registry.php on line 0
我正在运行Zend 1.9.1,Doctrine 1.1 on a窗口框。
I'm running Zend 1.9.1, Doctrine 1.1 on a windows box.
我的引导如下:
set_include_path(dirname(__FILE__).'/../library/zendframework'
. PATH_SEPARATOR . dirname(__FILE__).'/../library/doctrine'.....
require 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->suppressNotFoundWarnings(false);
$loader->setFallbackAutoloader(true);
从我所看到的,使用APC或xcache几乎是性能的必需品,但我可以似乎让它工作。任何想法?
From what I've read, using APC or xcache is almost a must for performance, but I can't seem to get it working. Any ideas?
推荐答案
你可以放一个 Zend_Session :: writeClose(true);
在你的index.php的结尾。
这将在必要的对象(Zend_Loader等)被破坏之前写入持久状态。
You could put a "Zend_Session::writeClose(true);
" at the end of your index.php.
This will write the session into a persistent state before necessary Objects (Zend_Loader etc.) get destructed.
更好:注册为。
所以即使你使用 exit()
, die )
或致命错误
发生:
Better: Register it as shutdown function.
So it will be executed even if you use exit()
, die()
or a fatal error
occures:
register_shutdown_function(array('Zend_Session', 'writeClose'), true);
这篇关于操作码(APC / XCache),Zend,Doctrine和Autoloaders的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!