Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating PHP files slow on MAMP

Tags:

php

mamp

Using MAMP, when I change a PHP file and save it, it takes 10-15 seconds for it to be available in my browser. HTML files update immediately. Example:

Example file:

<!DOCTYPE html>
<html>
<body>
<p>This is test</p>
</body>
</html>

When this file is named index.html and placed in MAMP/htdocs directory I can update it, save, open it at http://localhost/index.html and the update is there. If I simply rename the file to index.php (no php code), update and save, I can sit there and refresh browser for 10-20 seconds before I see the update (the old file reloads until the new version appears). I'm a rookie and new to server side scripting, so I'm not sure what is going on with an update to a PHP file - is there some processing that happens by Apache(?) before the file is able to be served? Is my PHP configuration a possible cause?

MacBook Pro osx10.8.5 2.8 Core2Duo 8GB (yes, it's old) -- MAMP 2.2 using port 80 -- PHP 5.5.3 -- Same behavior in all browsers -- Same behavior without an internet connection, so I don't think it is some DNS lookup issue

like image 618
user2876623 Avatar asked Mar 22 '23 01:03

user2876623


1 Answers

I had the same issue and found the answer here MAMP time between seeing live changes

I followed this instructions:

The solution is uncommenting lines in the php.ini file which can be found in /MAMP Directory/bin/php/php5.5.3/conf/php.ini

Comment out Opcache:

[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

Documentation (yes it started in 5.5):

http://www.php.net/manual/en/intro.opcache.php

like image 54
WaZzo Avatar answered Apr 05 '23 06:04

WaZzo