CLI MAMP PHP is slow compared to OS X PHP

I just had a problem running MAMP PHP very slowly. Ive reinstalled MAMP and still had problems.

As a comparison (I thought maybe my local OS OS machine for development might have had problems), I tried the following in the terminal and disabled php.ini with -n

 /usr/bin/php --version -n 

This returns the result immediately.

 /Applications/MAMP/bin/php/php5.5.14/bin/php --version -n 

This returns the output after about 3-5 seconds.

I tried to run many other commands and scripts. MAMP PHP seems to have a 3-5 second delay.

I have tried other versions of MAMP PHP and they still have the same problems.

I can not come up with anything that has recently changed on my machine to make it slow down (e..g no php.ini changes, OS X updates)

I really do not know what causes this problem, or even how to investigate the situation further. Help with thanks.

UPDATE

Strange, the only problem is that when you run MAMP PHP at the command line. When loading a website using MAMP does not slow down. Even more confusing ...

+8
command-line-interface php mamp
source share
2 answers

solved. For some reason, -n did not delete .ini files. Deleting the .ini file generally solved the problem.

Some searches lead me to the extension causing the problem. I commented on the next line in the .ini file.

 ; extension=imap.so 
+7
source share

As pointed out in other answers, the slowdown is caused by the imap.so extension.

If you delve deeper into this, it seems that the reason is that he is trying to perform a DNS lookup for the host name of the local computer.

Adding your hostname to the / etc / hosts file should be fixed:

 me@mbp ~> hostname mbp.local cat /etc/hosts ... 127.0.0.1 mbp.local ::1 mbp.local ... 

Before:

 me@mbp ~> time php -v PHP 7.0.12 (cli) (built: Oct 24 2016 18:49:11) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies **5.04 real** 0.01 user 0.01 sys 

After:

 me@mbp ~> time php -v PHP 7.0.12 (cli) (built: Oct 24 2016 18:49:11) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies **0.03 real** 0.01 user 0.00 sys 

I discovered this by capturing network traffic using Wireshark.

+14
source share

All Articles