Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting APC to play nice with spl_autoload_register

Tags:

php

autoload

apc

I am using the Zend Autoloader to load Zend classes for integrating Zend_AMF with my application. Everything was working perfectly until I installed APC 3.1.9 and enabled it.

I am getting this error:

Fatal error: Access to undeclared static property: Zend_Loader_Autoloader::$_instance in C:\blahblah

I am assuming that APC seems to have trouble with autoloaders and static properties and static methods.

APC is version 3.1.9 and is installed on a Windows 7 machine with PHP 5.3.8 running as fastCGI on an Apache 2.2 server.

Has anyone seen this error before? If so, what are some ways to fix this?

like image 407
F21 Avatar asked Oct 13 '11 03:10

F21


1 Answers

Looks like it was actually not the fault of the autoloader. APC sometimes does not play nice if you have a custom session handler.

The trick is to add this to the earliest part of your script (the first include if possible): register_shutdown_function('session_write_close');

This will tell PHP to finish writing and close (not destroy!) the session when the script finishes executing or is terminated (using exit() etc).

like image 108
F21 Avatar answered Nov 05 '22 10:11

F21