You’re developing your awesome new web project on localhost. But sooner or later, everything should be tested out in an environment as close as possible to a production set-up.
And you want to use the APC cache for that, which stores the PHP bytecode and recompiles source code only if it changes.
However, if you use MAMP (Pro) and try to use one of the PHP CLI (command line interface) tools (e.g. Symfony Console or Drush), you might be surprised with a bunch of errors.
The reason is simple. MAMP uses different php.ini configuration for CLI. You can locate this file easily in your terminal:
$ php -i | grep php.ini Configuration File (php.ini) Path => /Applications/MAMP/bin/php/php7.0.10/conf Loaded Configuration File => /Applications/MAMP/bin/php/php7.0.10/conf/php.ini
Open the file with your favorite editor:
$ vim /Applications/MAMP/bin/php/php7.0.10/conf/php.ini
By pressing /, typing ‘apc’ and pressing ENTER, you can locate the APC section of the configuration file. Just uncomment the following line (delete the leading ;) ):
There is, however, another issue. If your web application or CLI tool crashes, you need to clear the APC cache. That’s as simple as restarting your Apache / nginx server. If you cannot restart the servers, try following this manual to build an automated script.