Giter VIP home page Giter VIP logo

php-version's Introduction

simple PHP version switching

php-version exposes a php-version command allowing developers to switch between versions of PHP.

This IS for you if

  • You are not satisifed with heavy handed *AMP or PPA-based installers.
  • You use multiple versions of PHP on Linux or Mac.
  • You download pre-compiled PHP binaries for Windows (NOTE: this is a bash script so you'll need WSL).
  • You want to run your automated tests against multiple PHP versions.
  • You are a developer that works on a variety of PHP projects each requiring different versions of PHP.
  • You want to work on the latest PHP, but expect to support prior work that was done on older PHP versions.

This is NOT for you if

  • You are content with heavy handed *AMP installers.
  • You are provisioning a production server so you only need a single PHP install.
  • You NEVER work on more than one PHP project at a time.
  • You don't plan on supporting prior work that was done on other PHP versions.

Rationale

php-version attempts to stick to the classic UNIX notion that tools should do one thing well.

While there are smart alternative tools that attempt to solve this problem, none of the tools I've found were simple enough for me.

Features

  • Homebrew installed PHP versions are picked up automatically.
  • PHP versions installed into ~/.phps are picked up automatically.
  • PHP versions listed in the $PHP_VERSIONS shell variable are picked up automatically.
  • snap versioning: Use a partial version number (i.e. php-version 5) to automatically use the latest 5.x version.
  • per version php.ini: we export PHPRC if a version-specific php.ini exists.
  • configurable: php-version --help for details.
  • bash, zsh, and fish shells actively supported; though care has been taken such that other shells are likely to work as well.
  • tiny: less than 200 LOC; a single function sourced via your shell's initialization file.

Non-Features

  • no shims, sub-shells, symlinks or cd hooks.
  • we won't leave files and symlinks all over the place.
  • does not attempt to manage Apache, MySQL, etc.
  • does not attempt to compile, build, or install PHP.
  • does not attempt to support OS package manager installed (i.e. ppa, etc.) PHP versions.

Usage Examples

Switch to a specific PHP version

% php-version <version>

List installed and active (*) PHP version(s)

% php-version
  5.3.9
  5.3.10
  5.4.0RC8
  5.4.0RC6
  5.4.0
* 5.4.8

Install

homebrew (recommended for OSX users)

% brew tap wilmoore/formulae
% brew install php-version

cURL (for non-OSX users or those that prefer not to use homebrew):

% mkdir -p $HOME/local/php-version # or your place of choice
% cd !$
% curl -# -L https://github.com/wilmoore/php-version/tarball/master | tar -xz --strip 1

Alternative (i.e. non-Homebrew) installation methods are documented on the wiki.

Setup

Add one of the following to your shell's initialization file:

# Homebrew (recommended)
source $(brew --prefix php-version)/php-version.sh
php-version 5

# non-Homebrew
source $HOME/local/php-version/php-version.sh # or your place of choice
php-version 5

Type php-version --help for more configuration options such as how to add extra PHP installation paths or php-config --version to find out which php version is active.

If you have PHP versions in multiple directories, you can list them in the environment variable PHP_VERSIONS separated by spaces as depicted below:

export PHP_VERSIONS="$HOME/local/php $HOME/php/versions"

NOTE: do this before you source php-version.sh:

Deactivate / Uninstall

  1. Remove setup configuration.

  2. Enter one of the following commands listed below to remove associated files.

     # Homebrew (recommended)
     % brew remove --force php-version
    
     # non-Homebrew
     % rm -rf $HOME/local/php-version
    

Having Issues?

  1. Copy the bug report output to your clipboard (pbcopy works on Mac OSX; use your OS equivalent)

     % cd /tmp
     % git clone https://github.com/wilmoore/php-version.git
     % source php-version/bug-report.sh | pbcopy
    
  2. File an issue.

More Info

Contributors

https://github.com/wilmoore/php-version/graphs/contributors

Alternatives

Inspiration

LICENSE

MIT

php-version's People

Contributors

1ed avatar endelwar avatar erikdstock avatar jonphipps avatar josso avatar jpscharf avatar marlun avatar sharils avatar simonsimcity avatar szepeviktor avatar tooblue avatar tucksaun avatar wilmoore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-version's Issues

Missing System Version and Dirty PATH

  1. The system version is no longer in the php-version.
  2. The PATH will contain a path segment for each version of PHP switched to, so if we switch to 5.4 then to 5.5 we get something like the following:

``` /usr/local/Cellar/php55/5.5.4/bin:/usr/local/Cellar/php54/:/usr/local/Cellar/php54/5.4.20/bin:…````

php-version has been removed from homebrew

$ brew tap homebrew/homebrew-php
$ brew install php-version
Error: No available formula with the name "php-version"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
==> Searching local taps...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.

Readme is misleading about windows support

In the readme it mentions

This IS for you if

  • You download [pre-compiled PHP binaries for Windows][windows-bin].

No where else in the readme does it mention Windows support. Does this library support Windows or not? If it doesn't then this line should be removed as it isn't applicable.

Mistake on installing wiki page

Hi, i found some mistakes on this page:
https://github.com/wilmoore/php-version/wiki/Installing

git clone https://github.com/YOUR-USERNAME/php-version.git
"wilmoore" should be there instead of "YOUR-USERNAME"
git push, should not be there!

However, i can't use php-version,
When i try to run some commands with php-version, even --help, i got this message:
Sorry, but you do not seem to have any PHP versions installed.
See https://github.com/wilmoore/php-version#install for assistance.

But i have PHP 5.4.9-4ubuntu2.3 installed.
Maybe i'm doing something wrong? What can cause such message?

Thank you,
Dinu.

Re-write in a language that can produce a standalone binary

This will likely be rust but it isn't guaranteed. I originally considered go-lang; however, after evaluating it, I do not expect to write much code in it going forward.

If this gets enough interest, I may consider working on this sooner. Got lots on my plate so it would take some convincing to get me to move this up in priority.

homebrew/php was deprecated

When I execute "homebrew/php was deprecated" in my mac(mac os 10.13.3 (17D47)), �I got the error as follows:

Updating Homebrew...
Error: homebrew/php was deprecated. This tap is now empty as all its formulae were migrated.

doesn't switch between version 5.3.29 and 5.6.33

Switches fine between PHP 7.2 and 5.6 but not between 5.6 and 5.3 on OS X High Sierra.
Is this a Homebrew linking issue?

$ php-version 7.2.3
$ php --version
PHP 7.2.3 (cli) (built: Mar  8 2018 10:30:06) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.3, Copyright (c) 1999-2018, by Zend Technologies
$ php-version 5.3.29
$ php --version
PHP 7.2.3 (cli) (built: Mar  8 2018 10:30:06) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.3, Copyright (c) 1999-2018, by Zend Technologies
$ php-version
* 5.3.29
  5.6.33
  7.2.3
$ php-version 5.6.33
$ php-version
  5.3.29
* 5.6.33
  7.2.3
$ php --version
PHP 5.6.33 (cli) (built: Jan  7 2018 11:14:18) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

Support for hhvm

Is there any interest for adding support for HHVM here?

As it's a more and more growing alternative to the known PHP interpreter, it's may worth adding here as another way to execute PHP scripts.

[Feature] Switch PHP versions when entering in a project folder

Some similar tools, like phpenv/rbenv and similar projects, are automatically identifying the required php version you need for a certain project, by reading the content of a file in the project directory (for example: .php-version.

It would be very cool to have this feature here as well!

Example .php-version file:

7.0.15

I temporary implemented this by aliasing the cd command like this:

function cd() {
  for last; do true; done
  [ -f "$last/.php-version" ] && php-version $(cat $last/.php-version)
  builtin cd "$@"
}

Sorry, but php-version was unable to find version '5' under ''.

I am using zsh on Ubuntu 14.04 but I think I have missed something in setting up my .zshrc file. I have used php-builder and have built the latest php 5 and 7 versions within ~/local/php whilst php-version is installed in the default ~/local/php-version

I added this line to my .zshrc file - export PHP_VERSIONS="$HOME/local/php"

Using the command php-version without any commands returns nothing whilst defining an exact version yields the title error.

brew install doesn't create symlink

In 0.12.0, brew link php-version doesn't appear to create a symlink in /usr/local/bin.

Here's the content of the Cellar

    cd /usr/local/Cellar/php-version/0.12.0/
    ls -la
    total 56
    drwxr-xr-x  7 sminnee  admin   238 27 Aug 09:27 .
    drwxr-xr-x  3 sminnee  admin   102 27 Aug 09:27 ..
    -rw-r--r--  1 sminnee  admin   310 27 Aug 09:27 INSTALL_RECEIPT.json
    -rw-r--r--  1 sminnee  wheel  1080  2 Jul  2014 LICENSE
    -rw-r--r--  1 sminnee  wheel  6568  2 Jul  2014 README.md
    -rwxr-xr-x  1 sminnee  wheel   897  2 Jul  2014 bug-report.sh
    -rwxr-xr-x  1 sminnee  wheel  5521  2 Jul  2014 php-version.sh

And the content of INSTALL_RECEIPT.json

    sminnee@Walnut /u/l/C/p/0.12.0> cat INSTALL_RECEIPT.json 
    {"used_options":[],"unused_options":[],"built_as_bottle":false,"poured_from_bottle":false,"time":1440624479,"HEAD":"08bb15a8a5e4aa76c61a7f9f2a68b598b3ee6a00","stdlib":null,"compiler":"clang","source":{"path":"/usr/local/Library/Taps/homebrew/homebrew-php/Formula/php-version.rb","tap":"homebrew/homebrew-php"}}

Support for release-candidates installed by Homebrew

I installed the first release-candidate for PHP 5.6 today and was wondering why it wasn't marked as selected after calling php-version 5.6.

The reason is, that homebrew installs it to a directory called /usr/local/Cellar/php56/5.6.0-rc.1/bin, what is (correctly) added to the path variable, but it doesn't show up as marked, because the PHP binary returns 5.6.0RC1 as it's version number. Do you have an idea on to fix this? This may also apply to alpha or beta releases - haven't tested it yet.

One possibility (would take a tiny bit more time) would be to call each binary and compare the version-result instead of checking it by the name of the folder.

fish-shell not working

fishShell: https://github.com/fish-shell/fish-shell/
oh-my-fish: https://github.com/bpinto/oh-my-fish

~/.config/fish/config.fish

. $(brew --prefix php-version)/php-version.sh
fish: Illegal command name 'COLOR_NORMAL=$(tput sgr0)'
/usr/local/Cellar/php-version/0.10.4/php-version.sh (line 10):   COLOR_NORMAL=$(tput sgr0)
                                                                 ^
in . (source) call of file '/usr/local/Cellar/php-version/0.10.4/php-version.sh',
    called on standard input,

fish: Illegal command name 'COLOR_REVERSE=$(tput smso)'
/usr/local/Cellar/php-version/0.10.4/php-version.sh (line 11):   COLOR_REVERSE=$(tput smso)
                                                                 ^
in . (source) call of file '/usr/local/Cellar/php-version/0.10.4/php-version.sh',
    called on standard input,

fish: Illegal command name '[[ -n $(command -v brew) ]]'
/usr/local/Cellar/php-version/0.10.4/php-version.sh (line 25):   if [[ -n $(command -v brew) ]]; then
                                                                    ^
in . (source) call of file '/usr/local/Cellar/php-version/0.10.4/php-version.sh',
    called on standard input,

Add changelog

Awesome project!

It would be nice to add a CHANGELOG file.

No PHP versions installed

When running php-version on my Ubuntu machine I get the following error:

"Sorry, but you do not seem to have any PHP versions installed.
See https://github.com/wilmoore/php-version#install for assistance."

I'm not sure, but I think this was fixed by @jpscharf in commit: 4ccf753

But you've removed almost (if not all) that code 5 days later at commit: 072f514

When I check out https://github.com/jpscharf/php-version I do get the currently installed php version. But when I run php-version 5.2.4 I get the error message "Sorry, but php-version was unable to find version '5.2.4' under '' "

snap versioning (via fuzzy version string matching)

something like:

ls -1 | grep -vE '^\.' | grep N.N | sort -r | head -1

This is useful in case you want to configure your shell to snap to the latest major version installed. This alleviates the need to re-configure your version each time you upgrade.

For example, if I configure my shell to use php version 5.4, as soon as I install version 5.4.14, 5.4.14 is automatically the version my shell will use. I'll never have to change the configured 5.4 until I'm ready to move on to 5.5.

Can't find php.ini

When using php-version I've installed 5.4.11 and it works but I can't find where the php.ini is. phpinfo() tells me it's in ~/.phpversions/5.4.11/lib but all that I've got in there is a php folder.

If I run find . -name php.ini inside the 5.4.11 folder it gives me nothing.

[feature] port to go or rust

After version 1.0.0, port to go or rust so windows users have something they can use.

  • re-organize into bin and share directories.
  • update readme.md (install/setup section) to reflect changes.
  • include a man page for those that can utilize it

Doesn't switch versions on ubuntu

I've tried everything to fix this on my own. Even cloning the repo and trying a few changes myself to no avail. I've even toyed with the idea of uninstalling php completely and reinstalling it after installing this. I'm not sure what the issue is, but I know this worked just fine in the past.

Before setting PHP_VERSIONS in my bashrc file, I get the 'you have no php versions installed' message as expected. Once I set that, changing a version returns no output, but doesn't change the php version. I have 5.6, 7.0, 7.1 and 7.2 installed (7.2 active).

Then I installed linuxbrew-wrapper, and that didn't help. That's when I uninstalled it, gave up and came to submit this issue. Any ideas?

bug-report.sh output:
The program 'brew' is currently not installed. You can install it by typing:
sudo apt install linuxbrew-wrapper
The program 'brew' is currently not installed. You can install it by typing:
sudo apt install linuxbrew-wrapper

System

Linux phoenix 4.4.0-122-generic #146-Ubuntu SMP Mon Apr 23 15:34:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Script

TYPE: php-version
VERSION: php-version v0.12.0

Environment

SHELL: /bin/bash
PATH: /home/daraul/.nvm/versions/node/v9.8.0/bin:/home/daraul/.sdkman/candidates/gradle/current/bin:/home/daraul/bin:/home/daraul/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/daraul/.rvm/bin:/usr/local/Android/android-studio/bin:/usr/local/Android/Sdk/platform-tools:/usr/local/Android/Sdk/tools:/home/daraul/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1/bin:/home/daraul/.rvm/bin:/home/daraul/.config/composer/vendor/bin:/usr/local/Android/android-studio/bin:/usr/local/Android/Sdk/platform-tools:/usr/local/Android/Sdk/tools:/home/daraul/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1/bin:/home/daraul/.rvm/bin:/home/daraul/.config/composer/vendor/bin:/usr/local/Android/android-studio/bin:/usr/local/Android/Sdk/platform-tools:/usr/local/Android/Sdk/tools:/home/daraul/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1/bin:/home/daraul/.rvm/bin:/home/daraul/.config/composer/vendor/bin:/usr/local/Android/android-studio/bin:/usr/local/Android/Sdk/platform-tools:/usr/local/Android/Sdk/tools:/home/daraul/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1/bin:/home/daraul/.rvm/bin:/home/daraul/.config/composer/vendor/bin:/usr/local/Android/android-studio/bin:/usr/local/Android/Sdk/platform-tools:/usr/local/Android/Sdk/tools:/home/daraul/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1/bin:/home/daraul/.rvm/bin:/home/daraul/.config/composer/vendor/bin:/usr/local/Android/android-studio/bin:/usr/local/Android/Sdk/platform-tools:/usr/local/Android/Sdk/tools:/home/daraul/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1/bin:/home/daraul/.rvm/bin:/home/daraul/.config/composer/vendor/bin:/usr/local/Android/android-studio/bin:/usr/local/Android/Sdk/platform-tools:/usr/local/Android/Sdk/tools:/home/daraul/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1/bin:/home/daraul/.rvm/bin:/home/daraul/.config/composer/vendor/bin
PHPS:
PHP_VERSIONS: /etc/php/

Homebrew

VERSION:
PATH:
PHPS:

PHP

VERSION: 7.2.4-1+ubuntu16.04.1+deb.sury.org+1

INI

Configuration File (php.ini) Path: /etc/php/7.2/cli
Loaded Configuration File: /etc/php/7.2/cli/php.ini
Scan for additional .ini files in: /etc/php/7.2/cli/conf.d
Additional .ini files parsed: /etc/php/7.2/cli/conf.d/10-mysqlnd.ini,
/etc/php/7.2/cli/conf.d/10-opcache.ini,
/etc/php/7.2/cli/conf.d/10-pdo.ini,
/etc/php/7.2/cli/conf.d/15-xml.ini,
/etc/php/7.2/cli/conf.d/20-calendar.ini,
/etc/php/7.2/cli/conf.d/20-ctype.ini,
/etc/php/7.2/cli/conf.d/20-curl.ini,
/etc/php/7.2/cli/conf.d/20-dom.ini,
/etc/php/7.2/cli/conf.d/20-exif.ini,
/etc/php/7.2/cli/conf.d/20-fileinfo.ini,
/etc/php/7.2/cli/conf.d/20-ftp.ini,
/etc/php/7.2/cli/conf.d/20-gd.ini,
/etc/php/7.2/cli/conf.d/20-gettext.ini,
/etc/php/7.2/cli/conf.d/20-iconv.ini,
/etc/php/7.2/cli/conf.d/20-json.ini,
/etc/php/7.2/cli/conf.d/20-mbstring.ini,
/etc/php/7.2/cli/conf.d/20-mysqli.ini,
/etc/php/7.2/cli/conf.d/20-pdo_mysql.ini,
/etc/php/7.2/cli/conf.d/20-phar.ini,
/etc/php/7.2/cli/conf.d/20-posix.ini,
/etc/php/7.2/cli/conf.d/20-readline.ini,
/etc/php/7.2/cli/conf.d/20-shmop.ini,
/etc/php/7.2/cli/conf.d/20-simplexml.ini,
/etc/php/7.2/cli/conf.d/20-sockets.ini,The program 'brew' is currently not installed. You can install it by typing:
sudo apt install linuxbrew-wrapper
The program 'brew' is currently not installed. You can install it by typing:
sudo apt install linuxbrew-wrapper

System

Linux phoenix 4.4.0-122-generic #146-Ubuntu SMP Mon Apr 23 15:34:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Script

TYPE: php-version
VERSION: php-version v0.12.0

Environment

SHELL: /bin/bash
PATH: /home/daraul/.nvm/versions/node/v9.8.0/bin:/home/daraul/.sdkman/candidates/gradle/current/bin:/home/daraul/bin:/home/daraul/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/daraul/.rvm/bin:/usr/local/Android/android-studio/bin:/usr/local/Android/Sdk/platform-tools:/usr/local/Android/Sdk/tools:/home/daraul/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1/bin:/home/daraul/.rvm/bin:/home/daraul/.config/composer/vendor/bin:/usr/local/Android/android-studio/bin:/usr/local/Android/Sdk/platform-tools:/usr/local/Android/Sdk/tools:/home/daraul/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1/bin:/home/daraul/.rvm/bin:/home/daraul/.config/composer/vendor/bin:/usr/local/Android/android-studio/bin:/usr/local/Android/Sdk/platform-tools:/usr/local/Android/Sdk/tools:/home/daraul/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1/bin:/home/daraul/.rvm/bin:/home/daraul/.config/composer/vendor/bin:/usr/local/Android/android-studio/bin:/usr/local/Android/Sdk/platform-tools:/usr/local/Android/Sdk/tools:/home/daraul/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1/bin:/home/daraul/.rvm/bin:/home/daraul/.config/composer/vendor/bin:/usr/local/Android/android-studio/bin:/usr/local/Android/Sdk/platform-tools:/usr/local/Android/Sdk/tools:/home/daraul/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1/bin:/home/daraul/.rvm/bin:/home/daraul/.config/composer/vendor/bin:/usr/local/Android/android-studio/bin:/usr/local/Android/Sdk/platform-tools:/usr/local/Android/Sdk/tools:/home/daraul/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1/bin:/home/daraul/.rvm/bin:/home/daraul/.config/composer/vendor/bin:/usr/local/Android/android-studio/bin:/usr/local/Android/Sdk/platform-tools:/usr/local/Android/Sdk/tools:/home/daraul/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1/bin:/home/daraul/.rvm/bin:/home/daraul/.config/composer/vendor/bin
PHPS:
PHP_VERSIONS: /etc/php/

Homebrew

VERSION:
PATH:
PHPS:

PHP

VERSION: 7.2.4-1+ubuntu16.04.1+deb.sury.org+1

INI

Configuration File (php.ini) Path: /etc/php/7.2/cli
Loaded Configuration File: /etc/php/7.2/cli/php.ini
Scan for additional .ini files in: /etc/php/7.2/cli/conf.d
Additional .ini files parsed: /etc/php/7.2/cli/conf.d/10-mysqlnd.ini,
/etc/php/7.2/cli/conf.d/10-opcache.ini,
/etc/php/7.2/cli/conf.d/10-pdo.ini,
/etc/php/7.2/cli/conf.d/15-xml.ini,
/etc/php/7.2/cli/conf.d/20-calendar.ini,
/etc/php/7.2/cli/conf.d/20-ctype.ini,
/etc/php/7.2/cli/conf.d/20-curl.ini,
/etc/php/7.2/cli/conf.d/20-dom.ini,
/etc/php/7.2/cli/conf.d/20-exif.ini,
/etc/php/7.2/cli/conf.d/20-fileinfo.ini,
/etc/php/7.2/cli/conf.d/20-ftp.ini,
/etc/php/7.2/cli/conf.d/20-gd.ini,
/etc/php/7.2/cli/conf.d/20-gettext.ini,
/etc/php/7.2/cli/conf.d/20-iconv.ini,
/etc/php/7.2/cli/conf.d/20-json.ini,
/etc/php/7.2/cli/conf.d/20-mbstring.ini,
/etc/php/7.2/cli/conf.d/20-mysqli.ini,
/etc/php/7.2/cli/conf.d/20-pdo_mysql.ini,
/etc/php/7.2/cli/conf.d/20-phar.ini,
/etc/php/7.2/cli/conf.d/20-posix.ini,
/etc/php/7.2/cli/conf.d/20-readline.ini,
/etc/php/7.2/cli/conf.d/20-shmop.ini,
/etc/php/7.2/cli/conf.d/20-simplexml.ini,
/etc/php/7.2/cli/conf.d/20-sockets.ini,
/etc/php/7.2/cli/conf.d/20-sysvmsg.ini,
/etc/php/7.2/cli/conf.d/20-sysvsem.ini,
/etc/php/7.2/cli/conf.d/20-sysvshm.ini,
/etc/php/7.2/cli/conf.d/20-tokenizer.ini,
/etc/php/7.2/cli/conf.d/20-wddx.ini,
/etc/php/7.2/cli/conf.d/20-xmlreader.ini,
/etc/php/7.2/cli/conf.d/20-xmlrpc.ini,
/etc/php/7.2/cli/conf.d/20-xmlwriter.ini,
/etc/php/7.2/cli/conf.d/20-xsl.ini,
/etc/php/7.2/cli/conf.d/20-zip.ini
/etc/php/7.2/cli/conf.d/20-sysvmsg.ini,
/etc/php/7.2/cli/conf.d/20-sysvsem.ini,
/etc/php/7.2/cli/conf.d/20-sysvshm.ini,
/etc/php/7.2/cli/conf.d/20-tokenizer.ini,
/etc/php/7.2/cli/conf.d/20-wddx.ini,
/etc/php/7.2/cli/conf.d/20-xmlreader.ini,
/etc/php/7.2/cli/conf.d/20-xmlrpc.ini,
/etc/php/7.2/cli/conf.d/20-xmlwriter.ini,
/etc/php/7.2/cli/conf.d/20-xsl.ini,
/etc/php/7.2/cli/conf.d/20-zip.ini

add man page

  • re-organize into bin and share directories.
  • update readme.md (install/setup section) to reflect changes.

无法安装了

出现问题的MAC版本是:10.14.2
Error: homebrew/php was deprecated. This tap is now empty as all its formulae were migrated.

load and unload php-fpm plists and restart webserver?

@wilmoore would it be possible to have php-version also stop and start php-fpm and restart the active webserver?

Here is my bash scripts that do this currently:
go53

#!/bin/sh
# Written by Brian Gilbert @BrianGilbert_ https://github.com/BrianGilbert
# of Realityloop @Realityloop http://realitylop.com/

launchctl unload -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php53.plist 2&>1 >/dev/null
launchctl unload -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php54.plist 2&>1 >/dev/null
launchctl unload -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php55.plist 2&>1 >/dev/null
launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php53.plist
brew unlink php54
brew unlink php55
brew link php53
sudo /usr/local/bin/nginx -s reload

go55

#!/bin/sh
# Written by Brian Gilbert @BrianGilbert_ https://github.com/BrianGilbert
# of Realityloop @Realityloop http://realitylop.com/

launchctl unload -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php53.plist 2&>1 >/dev/null
launchctl unload -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php54.plist 2&>1 >/dev/null
launchctl unload -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php55.plist 2&>1 >/dev/null
launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php55.plist
brew unlink php53
brew unlink php54
brew link php55
sudo /usr/local/bin/nginx -s reload

Does not work with fish 3.1.0

Thanks for creating this simple and useful tool. I have been using it for a few years and now wanted to switch one machine to the fish shell, which is supported according to the README.

Is this an issue in my setup or is fish currently not supported by php-version?

Error:

$ source (brew --prefix php-version)/php-version.sh
/usr/local/opt/php-version/php-version.sh (line 47): Unexpected ')' found, expecting '}'
    -h|--help|-u|--usage)
                        ^
from sourcing file /usr/local/opt/php-version/php-version.sh
	called on line 11 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
	called during startup
source: Error while reading file '/usr/local/opt/php-version/php-version.sh'

Debug information:

## System

  Darwin <hostname> 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar  4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64

## Script

  TYPE:    NOT FOUND
  VERSION: NOT FOUND

## Environment

  SHELL:        /usr/local/bin/fish
  PATH:         /Users/lux/.composer/vendor/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin
  PHPS:         
  PHP_VERSIONS:

## Homebrew

  VERSION: Homebrew 2.2.11-114-g28a1497
           Homebrew/homebrew-core (git revision 1f6b068; last commit 2020-04-05)
           Homebrew/homebrew-cask (git revision a5780; last commit 2020-04-05)
  PATH:    /usr/local/bin/brew
  PHPS:    /usr/local/Cellar/php
           /usr/local/Cellar/[email protected]
           /usr/local/Cellar/[email protected]

## PHP

  VERSION: 7.4.4

## INI

  Configuration File (php.ini) Path: /usr/local/etc/php/7.4
  Loaded Configuration File:         /usr/local/etc/php/7.4/php.ini
  Scan for additional .ini files in: /usr/local/etc/php/7.4/conf.d
  Additional .ini files parsed:      /usr/local/etc/php/7.4/conf.d/ext-apcu.ini,
  /usr/local/etc/php/7.4/conf.d/ext-opcache.ini,
  /usr/local/etc/php/7.4/conf.d/ext-xdebug.ini

Remove version reporting on switch

Currently, we print the version switched to; however, this is a unix anti-pattern in that tools should be silent unless something is wrong.

No symlink for /usr/local/bin/php

I'm using brew and the different brew PHP versions.
Changing the version with brew, I would do:

brew unlink <current version> #e.g. brew unlink php56
brew link <new version>       #e.g. brew link php70

php-version only adjusts the PATH, not the actual symlinks.
Using PhpStorm, this means that each time I change the PHP version, I also have to re-set the path to the PHP binary in the settings, as I can't just point it to /usr/local/bin/php.

How do you solve this issue?

line 43: /usr/local/Library/ENV/4.3/sed: No such file or directory

Getting this error whenever my .bash_profile loads with source $(brew --prefix php-version)/php-version.sh && php-version 5 probably due to php-version 5. Here a list of output you may find helpful.

17:40 $ source php-version/bug-report.sh | pbcopy
: command not found
/usr/local/Cellar/php56/5.6.23/bin/php-config: line 43: /usr/local/Library/ENV/4.3/sed: No such file or directory
17:35 $ source ~/.bash_profile
/usr/local/Cellar/php56/5.6.23/bin/php-config: line 43: /usr/local/Library/ENV/4.3/sed: No such file or directory
17:37 $ php-version
  5.4.45
  5.6.22
* 5.6.23
17:37 $ php-version 5
/usr/local/Cellar/php56/5.6.23/bin/php-config: line 43: /usr/local/Library/ENV/4.3/sed: No such file or directory
17:37 $ php-version 4
Sorry, but php-version was unable to find version '4' under ''.
17:39 $ tree -d -L 4 $(find $(brew --cellar) -maxdepth 1 -type d) | grep -E 'php[0-9]*$'
├── php54
│       │   └── php
│       │   └── php
│       ├── php
├── php56
│   │   │   └── php
│   │   │   └── php
│   │   ├── php
│   │   │   └── php
│       │   └── php
│       │   └── php
│       ├── php
│       │   └── php
/usr/local/Cellar/php54
    │   └── php
    │   └── php
    ├── php
/usr/local/Cellar/php56
│   │   └── php
│   │   └── php
│   ├── php
│   │   └── php
    │   └── php
    │   └── php
    ├── php
    │   └── php

[ENHANCEMENT] reset path

As reported in #28.

The PATH will contain a path segment for each version of PHP switched to...

This is true; it was a design decision I made very early. The truth of the matter is, on a day-to-day basis; I don't switch versions in the same shell many times. That being said, it happens from time to time (i.e. couple times per month). When it does happen, the only thing that occurs, is that the path in only that particular shell session continues to grow with every switch.

That being said, it would be nice to have and I think that a feature like --reset which removes any/all switched versions from the path would be good and would likely satisfy #29 as well.

I would be happy to see this feature if it not complicated and not a lot of lines of code.

Supports .phpversion

Hi,
Thanks for this useful tool :-)
I wonder an improvement: as a lazy developer, I would find very useful to change automatically PHP version used in my project based on a .phpversion file included in it. For example, if my project handles a .phpversion file with 5.6 written in it, it will automatically apply php-version 5.6 when I enter this directory.
I don't know if I'm in the right place for this question, any comments are welcome :-)
Thanks

[ENHANCEMENT] system version

As requested in #28.

This is a nice-to-have (i.e. non-critical) since there are alternative ways to proceed; for instance:

  1. do not use system version -- it is usually outdated pretty quickly.
  2. install/compile a local version that matches the system version so you can switch to it.

That being said, if we can find a clean, maintainable, and low lines of code way to do this; great.

Can not work

Hello~~~I get problem!!Can you help me??
1.php70:
image

2.php71
image

3.~/.bash_profile(in my ~/.zshrc "")
image

image

4.Nothing!
image

5.bug-report

System

Darwin Birjemin-5.local 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64

Script

TYPE: php-version
VERSION: php-version v0.12.0

Environment

SHELL: /bin/zsh
PATH: /usr/local/opt/[email protected]/bin:/usr/local/opt/openssl/bin:/usr/local/opt/[email protected]/bin:/usr/local/opt/openssl/bin:/usr/local/opt/[email protected]/bin:/usr/local/opt/openssl/bin:/usr/local/opt/[email protected]/bin:/usr/local/opt/openssl/bin:/usr/local/opt/[email protected]/bin:/usr/local/opt/openssl/bin:/usr/local/Cellar/php70/7.0.27_19/bin:/usr/local/opt/[email protected]/bin:/usr/local/opt/openssl/bin:/usr/local/Cellar/php70/7.0.27.19/bin:/usr/local/opt/[email protected]/bin:/usr/local/opt/openssl/bin:/usr/local/Cellar/php70/7.0.27.19/bin:/usr/local/opt/[email protected]/bin:/usr/local/opt/openssl/bin:/usr/local/Cellar/php70/7.0.27.19/bin:/usr/local/opt/[email protected]/bin:/usr/local/opt/openssl/bin:/usr/local/opt/[email protected]/bin:/usr/local/opt/openssl/bin:/Users/birjemin/.nvm/versions/node/v9.0.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/birjemin/.composer/vendor/bin:GOBIN:/Library/Maven/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/birjemin/.composer/vendor/bin:GOBIN:/Library/Maven/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/birjemin/.composer/vendor/bin:GOBIN:/Library/Maven/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/birjemin/.composer/vendor/bin:GOBIN:/Library/Maven/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/birjemin/.composer/vendor/bin:GOBIN:/Library/Maven/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/birjemin/.composer/vendor/bin:GOBIN:/Library/Maven/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/birjemin/.composer/vendor/bin:GOBIN:/Library/Maven/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/birjemin/.composer/vendor/bin:GOBIN:/Library/Maven/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/birjemin/.composer/vendor/bin:GOBIN:/Library/Maven/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/birjemin/.composer/vendor/bin:GOBIN:/Library/Maven/bin
PHPS:
PHP_VERSIONS: /usr/local/Cellar/php70 /usr/local/Cellar/php71

Homebrew

VERSION: Homebrew 1.6.6
Homebrew/homebrew-core (git revision 70def; last commit 2018-06-04)
PATH: /usr/local/bin/brew
PHPS:

PHP

VERSION: 7.0.27

INI

Configuration File (php.ini) Path: /usr/local/etc/php/7.0
Loaded Configuration File: /usr/local/etc/php/7.0/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.0/conf.d
Additional .ini files parsed: /usr/local/etc/php/7.0/conf.d/ext-igbinary.ini,
/usr/local/etc/php/7.0/conf.d/ext-memcached.ini,
/usr/local/etc/php/7.0/conf.d/ext-mongodb.ini,
/usr/local/etc/php/7.0/conf.d/ext-redis.ini,
/usr/local/etc/php/7.0/conf.d/ext-swoole.ini,
/usr/local/etc/php/7.0/conf.d/ext-tideways_xhprof.ini,
/usr/local/etc/php/7.0/conf.d/ext-xdebug.ini,
/usr/local/etc/php/7.0/conf.d/ext-xhprof.ini

init script is not finding my brew-installed php versions. all installed today.

Was looking for a php version manager when i came upon this.

System

Darwin Eriks-MacBook-Pro.local 14.5.0 Darwin Kernel Version 14.5.0: Tue Sep 1 21:23:09 PDT 2015; root:xnu-2782.50.1~1/RELEASE_X86_64 x86_64

Script

TYPE: php-version
VERSION: php-version v0.12.0

Environment

SHELL: /bin/bash
PATH: /Users/eriks/.rvm/gems/ruby-2.1.4/bin:/Users/eriks/.rvm/gems/ruby-2.1.4@global/bin:/Users/eriks/.rvm/rubies/ruby-2.1.4/bin:/usr/local/bin:/usr/local/sbin:~/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/eriks/Documents/android/sdk/build-tools:/Users/eriks/Documents/android/sdk:/Users/eriks/Documents/android/sdk/platform-tools:/Users/eriks/Documents/android/sdk/tools:/Users/eriks/.rvm/bin:/Users/eriks/.rvm/bin
PHPS:
PHP_VERSIONS:

Homebrew

VERSION: 0.9.5 (git revision 9b85e; last commit 2015-11-23)
PATH: /usr/local/bin/brew
PHPS: /usr/local/Cellar/�php56

PHP

VERSION: 5.6.15

INI

Configuration File (php.ini) Path: /usr/local/etc/php/5.6
Loaded Configuration File: /usr/local/etc/php/5.6/php.ini
Scan for additional .ini files in: /usr/local/etc/php/5.6/conf.d
Additional .ini files parsed: (none)

Unable to run from within a script?

I get the following error when trying to run php-version from within a script:

/usr/local/opt/php-version/php-version.sh: line 136: `php-version': not a valid identifier

Example of script:

brew install php-version
echo  'source $(brew --prefix php-version)/php-version.sh && php-version 5' >> ~/.bash_profile
echo  'source $(brew --prefix php-version)/php-version.sh && php-version 5' >> ~/.zshrc
source $(brew --prefix php-version)/php-version.sh && php-version 5
php-version 5.3

I change the php version but the php-fpm does not change

when I use php-version change my php, in the cli environment,it does change, but the php-fpm still keep the old version . I do like this :

php70 () {
    php-version 7.0
    brew unlink php56 
    brew unlink php70 && brew link php70
    sudo brew services stop php56
    brew services stop php56
    brew services restart php70
    valet domain app 
}

and call the function php70 in iterm2

And it works.

I miss something ? My posture is not right?

brew versions not picked up anymore

Brew seems to have migrated PHP into the Core repository:

https://github.com/Homebrew/homebrew-php:

As announced on the 19th of January this tap was archived on 31st March 2018.

All formulae were migrated to Homebrew/homebrew-core or deleted by 7th April.

As a result, PHP is now called [email protected], [email protected], etc.

However, php-version matches the php versions by php70, php71, you get the drill:
https://github.com/wilmoore/php-version/blob/master/php-version.sh#L31

Adjusting the pattern to use php@[0-9\.]*$ fixes the problem.

This probably needs a better, more backwards compatible solution. But I'd appreciate a fix.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.