wilmoore / php-version

stupid simple PHP version management
https://github.com/wilmoore/php-version
MIT License
678 stars 51 forks source link

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

Closed ProGM closed 7 years ago

ProGM commented 7 years ago

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 "$@"
}
wilmoore commented 7 years ago

Hi @ProGM,

I personally use direnv for that. https://github.com/wilmoore/php-version/issues/57

Currently, you can add a custom function to direnv called use_php; however, at some point, I (or someone else with some free cycles) will add this to the stdlib of direnv so it will have this capability out of the box.

Hope this helps.