Basculer de version locale de PHP avec Brew pour macOS

Publié le 01/01/2021 • Actualisé le 01/01/2021


English language detected! 🇬🇧

  We noticed that your browser is using English. Do you want to read this post in this language?

Read the english version 🇬🇧 Close

Dans ce bout de code, nous allons voir comment basculer de version locale de PHP avec Brew pour MacOS. Je n'utilisais pas beaucoup cela dans le passé car c'était OK de développer avec PHP 7.4 quand on travaillait sur un projet verrouillé à PHP 7.2 en utilisant l'option "PHP Language level" de PHPStorm. Avec l'arrivée de PHP 8 ce n'est plus possible. Avec ces quelques raccourcis, on peut changer de version de PHP en moins d'une seconde.


## —— PHP 🐘 (macOS with brew) —————————————————————————————————————————————————
php-upgrade: ## Upgrade PHP to the last version
	@$(BREW) upgrade php

php-set-8-2: ## Set php 8.2 as the current PHP version
	@$(BREW) unlink php
	@$(BREW) link --overwrite php@8.2

php-set-8-3: ## Set php 8.3 as the current PHP version
	@$(BREW) unlink php
	@$(BREW) link --overwrite php@8.3

php-set-8-1: ## Set php 8.1 as the current PHP version
	@$(BREW) unlink php
	@$(BREW) link --overwrite php@8.1

#[12:36:23] coil@mac-mini.home:/Users/coil/Sites/strangebuzz.com$ php -v
#PHP 7.4.13 (cli) (built: Nov 30 2020 14:33:39) ( NTS )
#Copyright (c) The PHP Group
#Zend Engine v3.4.0, Copyright (c) Zend Technologies
#with Zend OPcache v7.4.13, Copyright (c), by Zend Technologies

#[12:36:32] coil@mac-mini.home:/Users/coil/Sites/strangebuzz.com$ make php-set-8-0
#brew unlink php
#Unlinking /usr/local/Cellar/php/8.0.0_1... 0 symlinks removed
#brew link --overwrite php@8.0
#Unlinking /usr/local/Cellar/php@7.4/7.4.13_1... 25 symlinks removed
#Linking /usr/local/Cellar/php/8.0.0_1... 24 symlinks created

#[12:36:35] coil@mac-mini.home:/Users/coil/Sites/strangebuzz.com$ php -v
#PHP 8.0.0 (cli) (built: Nov 30 2020 13:43:08) ( NTS )
#Copyright (c) The PHP Group
#Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
#with Zend OPcache v8.0.0, Copyright (c), by Zend Technologies

 Plus sur Stackoverflow   Lire la doc  Snippet aléatoire

  Travaillez avec moi !