Disable OPCache
MAMP now turns on OPCache by default, you can disable it by editing your php.ini file. Make sure you edit the correct php.ini.
I was running into the same problem myself. MAMP with PHP version 5.5.3 runs OPcache by default, but you can't turn it off in the GUI like you can with the older PHP version 5.2.17. You have to manually comment out all the OPcache lines at the end of the php.ini file (MAMP/bin/php/[version]/conf/php.ini) and make sure to stop and start the servers for the changes to take effect.
I updated the URI, the changes can be reflective by also changing /conf/ under the php folder, but it seems MAMP will ignore these after restart.
I added opcache_reset(); in my main PHP to stop this caching.
Removing it from php5.5.3/conf/php.ini
did nothing for me.
Edit
Turns out there also is a /Applications/MAMP/bin/php/php5.5.3/conf/php.ini
. It
works if I comment it out there.
1) in /Applications/MAMP/bin/php/php5.5.3/conf/php.ini
2) set opcache.revalidate_freq=0
3) restart MAMP
Took me so long to figure out it was a MAMP problem! Why would OPcache be enabled by default-- and require php.ini tinkering to disable-- in an app that's supposed to be used for testing websites? Anyway, I read through this whole thread and tried the various solutions.
Here are my notes on how each solution works and considerations for selecting a solution.
Each solution works on its own; no need for redundancy.
<?php opcache_reset(); ?>
Important: Use the php.ini
file in /Applications/MAMP/bin/php/php5.5.3/conf/php.ini
and not in
/Applications/MAMP/conf/php5.5.3/php.ini
. Adjust accordingly if you're using a different version of PHP.
[OPcache]
zend_extension="/Applications/MAMP/bin/php/php5.5.3/lib/php/extensions/no-debug-non-zts-20121212/opcache.so"
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1
enable=0
[OPcache]
in php.ini
.[OPcache]
zend_extension="/Applications/MAMP/bin/php/php5.5.3/lib/php/extensions/no-debug-non-zts-20121212/opcache.so"
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=0
opcache.fast_shutdown=1
opcache.enable_cli=1
opcache.revalidate_freq
under [OPcache]
in php.ini
.;[OPcache]
;zend_extension="/Applications/MAMP/bin/php/php5.5.3/lib/php/extensions/no-debug-non-zts-20121212/opcache.so"
;opcache.memory_consumption=128
;opcache.interned_strings_buffer=8
;opcache.max_accelerated_files=4000
;opcache.revalidate_freq=60
;opcache.fast_shutdown=1
;opcache.enable_cli=1
[OPcache]
section in php.ini
.Choose the webpage code solution if:
Choose a server configuration solution if:
I personally prefer enable=0
since it's the simplest solution for me, and I need caching disabled by default.
It looks like this is finally a GUI option. MAMP 3.0.7.2 for Mac OS X
.
It was painful spending around 1 hour trying to figure out what could it be.
I just added this at the end of the code and restart MAMP.
opcache.revalidate_freq=0
opcache_reset();
Edit "/Applications/MAMP/conf/php5.5.3/php.ini", and search for [OPcache] and add this code under it directly:
opcache.enable=0
This will disable opcache in when use PHP in MAMP server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With