Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jalendport/switch-php
Easily switch between PHP versions on your Mac. Requires Homebrew and works with Laravel Valet. 🔀
https://github.com/jalendport/switch-php
cli laravel-valet php php-versions php5 php7 php70 php71 php72 shell shell-script shell-scripts terminal valet
Last synced: about 1 month ago
JSON representation
Easily switch between PHP versions on your Mac. Requires Homebrew and works with Laravel Valet. 🔀
- Host: GitHub
- URL: https://github.com/jalendport/switch-php
- Owner: jalendport
- License: mit
- Created: 2018-03-23T14:13:49.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-10-09T05:22:52.000Z (about 3 years ago)
- Last Synced: 2024-09-28T08:21:03.460Z (about 2 months ago)
- Topics: cli, laravel-valet, php, php-versions, php5, php7, php70, php71, php72, shell, shell-script, shell-scripts, terminal, valet
- Language: Shell
- Homepage: https://www.npmjs.com/package/switch-php
- Size: 20.9 MB
- Stars: 123
- Watchers: 3
- Forks: 27
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# 🔀 switch-php
Easily switch between PHP versions on your Mac. Requires Homebrew and works with Laravel Valet.
![switch-php screencast](./switch-php.gif)
### ⬇️️️ Installation:
Installing `switch-php` is as easy as running:
```
npm install --global switch-php
```If you use Yarn, you can do this:
```
yarn global add switch-php
```Alternatively you can move the `switch-php.sh` file from this repo into your home directory and add this line in your `.bashrc`/`.zshrc`/etc.:
```
source ~/switch-php.sh
```### ⚙ Usage:
You must have PHP installed via Homebrew in order for `switch-php` to work. `switch-php` also works really well with Laravel Valet, but Valet is not a requirement in order to use `switch-php`.
Here's an example of how you would use `switch-php`:
```
$ switch-php 7.1 -v -m 512M
```1. `switch-php` -> The main command. (Required)
1. `7.1` -> Specify the version of PHP you want to switch too, in this case `php71`. (Required)
1. `-v` -> Request verbose output (Optional)
1. `-m 512M` -> Request a custom PHP memory setting. If you don't pass an additional arugment, the memory will be reset to the Valet default. (Optional)Here's the full list of versions/options:
```bash
Usage:
version [options] [arguments]Options:
-h, --help Display the help message
-v, --verbose Display more info during the process
-m, --memory Customize the PHP memory setting (Valet only)Available Versions:
5.6 Switch to [email protected]
7.0 Switch to [email protected]
7.1 Switch to [email protected]
7.2 Switch to [email protected]
7.3 Switch to [email protected]
7.4 Switch to [email protected]
```### 🎛 Customizing the PHP Memory Settings:
- If you don't pass an argument to `-m` or `--memory`, it will reset any previously set custom memory settings to the default Valet config.
- Alternatively, you can pass an argument to `-m` or `--memory` if you want to override the default Valet memory settings. For example, you can do:```
switch-php 7.1 -m 512M # [email protected] with 512MB of memory
switch-php 7.3 -m 2G -v # [email protected] with 2GB of memory; verbose output
switch-php 5.6 --memory=1G # [email protected] with 1GB of memory
```- *Note: customizing PHP memory settings currently only works for Laravel Valet users. If you don't use Valet, we hope to get this working for you as well in an upcoming release.*