Using APC in PHPUnit - APC returns false

December 24th 2013

Recently, I've taken my somewhat bizarre need to unit test things to a new level.

I've adopted the "if you can't test it, don't do it" approach. This is great, but I hit a stumbling block.

APC seemed to not work when running phpunit. This put a big blocker in my way, but I've figured out how to get it working.

Edit your php.ini for CLI. On Ubuntu it's in:

Text Snippet:
/etc/php5/cli/php.ini

Add this to the bottom of the file:

Text Snippet:
apc.enable_cli=1

Run PHPUnit again, and see if that resolves the problem, if not, you may not have the APC driver enabled. Do it by adding this above the 'apc.enable_cli' line:

Text Snippet:
extension=apc.so

So, if you've had the problem of apc returning false then this fixes it.

apc_store, apc_fetch, apc_delete, apc_clear_cache

Oh, Merry Christmas ;)