Skip to content

gtsvetanov/brew-php-switcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Homebrew PHP version switcher

Build status macOS architectures supported macOS architectures supported LICENSE PHP Versions Supported

Homebrew PHP version switcher is a simple script to switch between homebrew installed php versions for users using macOS.

Caveats

macOS

This script is working only on macOS and it was tested only on Monterey. It may work on Big Sur and even older versions like Catalina and Mojave but you have to use it caution.

Apache

For best experience use Homebrew Apache 2.x version instead of macOS built-in Apache.

PHP versions

This script will automatically detect which php versions are installed on your machine via homebrew

To install legacy php versions (like 5.6) you can use shivammathur/homebrew-php.

Installation

git clone [email protected]:gtsvetanov/brew-php-switcher.git ./
cd brew-php-switcher
chmod +x brew-php-switcher.sh
mv brew-php-switcher.sh /usr/local/bin/brew-php-switcher

Usage

brew-php-switcher <version> [-a | -f | -v | -h] 

Options

-a|--apache - This option will change your Apache 2.x configuration

# Setting CLI php version 8.1 and change Apache configuration to use the same version
brew-php-switcher 8.1 -a 

-f|--fpm - This option will change your PHP-FPM configuration

# Setting CLI php version 8.1 and PHP-FPM to use the same version
brew-php-switcher 8.1 -f 

-v|--valet - This option will change your Laravel Valet configuration

# Setting CLI php version 8.1 and Laravel Valet to use the same version
brew-php-switcher 8.1 -v 

-h|--help - This option will print help message

# Prints help message
brew-php-switcher -h

Examples

# Changes CLI / Apache / PHP-FPM and Laravel Valet to 5.6
brew-php-switcher 5.6 -a -f -v

# Changes CLI / Apache / PHP-FPM and Laravel Valet to 7.0
brew-php-switcher 7.0 -a -f -v

# Changes CLI / Apache / PHP-FPM and Laravel Valet to 7.1
brew-php-switcher 7.1 -a -f -v

# Changes CLI / Apache / PHP-FPM and Laravel Valet to 7.2
brew-php-switcher 7.2 -a -f -v

# Changes CLI / Apache / PHP-FPM and Laravel Valet to 7.3
brew-php-switcher 7.3 -a -f -v

# Changes CLI / Apache / PHP-FPM and Laravel Valet to 7.4
brew-php-switcher 7.4 -a -f -v

# Changes CLI / Apache / PHP-FPM and Laravel Valet to 8.0
brew-php-switcher 8.0 -a -f -v

# Changes CLI / Apache / PHP-FPM and Laravel Valet to 8.1
brew-php-switcher 8.1 -a -f -v

Helpful links

About

Homebrew PHP version switcher

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages