philcook / brew-php-switcher

Brew PHP switcher is a simple shell script to switch your apache and CLI quickly between major versions of PHP. If you support multiple products/projects that are built using either brand new or old legacy PHP functionality. For users of Homebrew (or brew for short) currently only.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Autoswitch $PATH for CLI

Goon3r opened this issue · comments

Hello,

Im wondering if a method of auto swithcing the $PATH variable for the PHP CLI can be created for this package? I imagine with the patterns in the .bash_profile declartions this is something that is doable.

#export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"
export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH"

Thanks for the package, really nice work!

@Goon3r I didnt want to mess with users .bash_profiles as there are many custom configs users have done.

Currently it switches the CLI based on unlinking all versions of php and linking up the desired version. See lines 76 and 79.

Does the CLI not switch for you? Are you testing with php -v

Thanks for the response.

Realised it was a mistake on my part.
On install of homebrew php packages it gives the following caveat
Export line changes depending on versions


✩✩✩✩ PHP CLI ✩✩✩✩

If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc,
~/.zshrc, ~/.profile or your shell's equivalent configuration file:

      export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH"

Commenting all of these lines seems to fix this issue.

Awesome glad you got things sorted.