If you have another version installed in the Brew's Cellar directory, make sure to brew unlink php
it and possibly also delete the version folder.
Then, simply download the latest version of PHP source and run the configure command below, then continue as usual with make && make install
. Afterwards, activate the installation by brew link php
.
Note: You will need to install any pecl extensions (like xdebug) again after this procedure.