Created
May 2, 2021 16:15
-
-
Save binsarjr/8b5415f5e439f075d35994acf35e35bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# function untuk mengubah versi php-cli | |
# taruh di .bashrc supaya sudah autoload | |
function switch_php() { | |
PHPFILE=/usr/bin/php$1 | |
if test -f "$PHPFILE"; then | |
sudo update-alternatives --set php $PHPFILE | |
fi | |
PHPFILE=/usr/bin/phar$1 | |
if test -f "$PHPFILE"; then | |
sudo update-alternatives --set phar $PHPFILE | |
fi | |
PHPFILE=/usr/bin/phpize$1 | |
if test -f "$PHPFILE"; then | |
sudo update-alternatives --set phpize $PHPFILE | |
fi | |
PHPFILE=/usr/bin/php-config$1 | |
if test -f "$PHPFILE"; then | |
sudo update-alternatives --set php-config $PHPFILE | |
fi | |
PHPFILE=/usr/bin/phar.phar$1 | |
if test -f "$PHPFILE"; then | |
sudo update-alternatives --set phar.phar $PHPFILE | |
fi | |
} | |
# Penggunaan: | |
# switch_php x.x | |
# contoh: | |
# switch_php 8.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gambaran
$ php -v
PHP 7.4.3 (cli) (built: Oct 6 2020 15:47:56) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
$ switch_php 8.0
update-alternatives: using /usr/bin/php8.0 to provide /usr/bin/php (php) in manual mode update-alternatives: using /usr/bin/phar8.0 to provide /usr/bin/phar (phar) in manual mode update-alternatives: using /usr/bin/phar.phar8.0 to provide /usr/bin/phar.phar (phar.phar) in manual mode
$ php -v
PHP 8.0.3 (cli) (built: Mar 5 2021 07:54:13) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.3, Copyright (c) Zend Technologies with Zend OPcache v8.0.3, Copyright (c), by Zend Technologies