PHP incredibly slow since upgrading macOS to 10.14 Mojave? Since I upgraded my Mac to Mojave 10.14, I noticed PHP is incredibly slow.

When I do this from the terminal:

php -v

It takes about 4-5 seconds before showing the version number, which is: PHP 7.1.13 (cli) (built: Feb  1 2018 13:38:42) ( NTS )

Is there a way to fix this? And, perhaps upgrade to the latest PHP (currently 7.2) while I'm at it?
I faced a similar issue on Mojave update, I was able to fix it by updating /etc/hosts file with 

::1             localhost YouMacName.local
127.0.0.1       localhost YouMacName.local


You can get YourMacName.local by running in terminal:

$ hostname


I hope it helps you