NasirNobin / zsh-valet

This zsh plugin will read `.valetphprc` from the project root and will switch to that PHP version automatically real time
MIT License
9 stars 1 forks source link

Automatically detect valet isolated and global versions? #3

Open jesseleite opened 2 years ago

jesseleite commented 2 years ago

Works great! Thank you for your work on this! ❤️

Curious also... Is it possible for zsh-valet to automatically read php versions from valet (the global default version, as well as isolated versions), rather than having to set a matching .valetphprc files and default version in our zshrc?

jesseleite commented 2 years ago

Oh I see in https://github.com/laravel/valet/pull/1216 that you are proposing valet which-php 😮 ...If that gets merged, maybe zsh-valet can use valet which-php to automatically determine the correct php version without the neeed for .valetphprc? 🙏

NasirNobin commented 2 years ago

Thanks for the kind words @jesseleite!

This idea sounds great. Love it. I'll dig and see if we can make it work! Though valet which-php would be a bit expensive to run on each zsh directory change hook. I think we need to find a more performant way to handle this.

jesseleite commented 2 years ago

@NasirNobin Was thinking about that too...

Maybe laravel/valet could cache a single flat file somewhere, with the global php version, as well as site paths that are on isolated versions. This way tools like zsh-valet would only have to read a single file that already has all the paths/versions resolved. Thoughts?

NasirNobin commented 2 years ago

That could work. I'll see if can draft something like that once valet which-php PR is merged.

NasirNobin commented 2 years ago

btw, I had another idea. Instead of relying on which-php we can utilize valet isolated command and create a site:version map in real-time from our zsh plugin and probably cache it somewhere locally.

jesseleite commented 2 years ago

That sounds awesome! 💪

Also what about for detecting the global php version in valet? Would be nice to do away with this, so that users don't have to keep this exported var in sync...

export VALETPHPRC_DEFAULT_PHP=php@8.1
NasirNobin commented 2 years ago

That's on my todo as well 🙌