For php56
$ brew install php56 –with-httpd
$ brew install php56-xdebug
If you wish to install php71 , you do not need to remove it, just install it, brew will remove php56
$ brew install php71 –with-httpd –with-pear
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so
SetHandler application/x-httpd-php
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
The php.ini and php-fpm.ini file can be found in:
/usr/local/etc/php/7.1/
For php 7.1 install xdebug using pecl
/usr/local/Cellar/php@7.1/7.1.16/bin/pecl search xdebug
/usr/local/Cellar/php@7.1/7.1.16/bin/pecl install xdebug
xdebug config files are in:
/usr/local/etc/php/5.6/conf.d/ext-xdebug.ini
/usr/local/etc/php/7.1/conf.d/ext-xdebug.ini
you don’t need to reinstall to switch in apache, just edit and restart
vi /usr/local/etc/httpd/httpd.conf
and enable the line of the version you need:
#LoadModule php5_module /usr/local/Cellar/php56/5.6.32_8/libexec/apache2/libphp5.so
LoadModule php5_module /usr/local/Cellar/php56/5.6.36/lib/httpd/modules/libphp5.so
/usr/local/bin/apachectl -k restart