Skip to content

This zsh plugin will read `.valetphprc` from the project root and will switch to that PHP version automatically real time

License

Notifications You must be signed in to change notification settings

NasirNobin/zsh-valet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

ZSH Valet

This zsh plugin will read .valetphprc from the project root and will switch to that PHP version automatically real time. So php artisan & composer commands will always run on the project's PHP version when you are using Valet's site isolation feature!

Here's a quick video demonstration
CleanShot.2022-03-15.at.13.32.49.mp4

Install (oh-my-zsh)

  1. Clone this repository in oh-my-zsh's plugins directory:
git clone https://github.com/NasirNobin/zsh-valet ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-valet
  1. Activate the plugin in ~/.zshrc:
plugins=( [plugins...] zsh-valet)
  1. Create a file named .valetphprc in your project directory with following project's PHP version. Example:
php@8.1
  1. Optionally, You can define a default PHP version on your .zshrc. This will be used to reset PHP Binary when you exit a project directory. (Make sure to put before the plugins=( [plugins...] zsh-valet) block)
VALETPHPRC_DEFAULT_PHP=php@8.0
  1. Restart zsh (such as by opening a new instance of your terminal emulator). Now when you cd into your project directory. It should automatically swap to .valetphprc defined PHP binary for that session.

Install (non oh-my-zsh)

Simply clone this repository and source the script:

git clone https://github.com/NasirNobin/zsh-valet
echo "source ${(q-)PWD}/zsh-valet/zsh-valet.plugin.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc

Show PHP Version Output

If you want to show the PHP version change add this to your ~/.zshrc.

export VALETPHPRC_SHOW_PHP_VERSION_CHANGE=1

Recommended PHP installation method

If for some reason this plugin doesn't work with your environment. We recommend you uninstall your PHP versions and reinstall with the following method.

brew tap shivammathur/php


# install your required php versions
brew install shivammathur/php/php@8.1
brew install shivammathur/php/php@8.0
brew install shivammathur/php/php@7.4
brew install shivammathur/php/php@7.3
brew install shivammathur/php/php@7.2
brew install shivammathur/php/php@7.0
brew install shivammathur/php/php@5.6

Beta Testing

This is still very early version of this plugin. If you see any issues, please open an issue on this repository. Also this seems to work fine on my M1 Mac, I still haven't tested it on Intel Mac (i think homebrew stores the php binary in a different directory on Intel Mac, so it might not work there yet)

About

This zsh plugin will read `.valetphprc` from the project root and will switch to that PHP version automatically real time

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages