Opcode (APC/XCache), Zend, Doctrine, and Autoloaders
apc, doctrine, opcode, xcache, zend-framework
Solution
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.
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);
Problem
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. 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 ``` 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 ``` I'm running Zend 1.9.1, Doctrine 1.1 on a windows box. My bootstrap is as follows: ``` 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); ``` 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?