Install php Multi version
Day by day everything are moving or changing it's not like how I love my wife still the same 😅 . Anyway this content we are talking about how to install and use PHP multi version in the one computer(Mac).
So why multi PHP version?
It's because a dev will develop multi project and each project are stick with different PHP version.
Installing :
Install only any versions you need.
brew tap shivammathur/phpbrew install shivammathur/php/php@7.2brew install shivammathur/php/php@7.3brew install shivammathur/php/php@7.4brew install shivammathur/php/php@8.0brew install shivammathur/php/php@8.1
Tell computer to use one PHP version as default
brew unlink phpbrew link --overwrite --force php@7.4
In case you want to switch to any version you can just update php@version
After doing this you can test on terminal by type php -v to see if it work
Define port to each version
Example below I use PHP version 7.4 if you wish to change any version just change it
/etc/php/version/php-fpm.d/www.conf
code /usr/local/etc/php/7.4/php-fpm.d/www.conf
Apple Silicon M1 Chipset
code /opt/homebrew/etc/php/7.4/php-fpm.d/www.conf
Update content below to change your port and port will be used for php-fpm to separate each version
This way you can config your Apache or Nginx to use PHP by 127.0.0.1:port . Totally port is represent of PHP version.
# default
user = _www
group = _www
listen = 127.0.0.1:9000
# change to
user = {your_username}
group = _www
listen = 127.0.0.1:9074