Valet Isolate and using the correct version of PHP with Composer
With Valet 3 and the isolate command you can now specify which version of PHP a specific project is supposed to use. I just upgraded Valet and the isolate works just fine, and I am able to run a legacy app in Laravel 6 using PHP 7.4 and a new app in Laravel 8 and PHP 8.1.
The problem I am running in to is that when I try to run composer on the Laravel 8 project, composer seems to be using PHP7.4, unless I specify by using valet use [email protected] which defeats the purpose of using valet isolate. I saw on Laravel News that you can create a symlink in the PATH to get the CLI to run commands using the right version of PHP, but I'm stuck on how to get that to work. I can't figure out how to make the right symlink.
and when I try to run that command, I get this error:
ln: /Users/garrettmassey/bin/php74: No such file or directory
so my issue is that I'm not sure where the right path is to create the symlink so that I can run composer in each directory with the corresponding PHP version that Valet is using.
@tykus That worked to make the symlink, but when I try to run commands in the terminal for PHP8 (like php artisan or composer I get the error:
Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.2". You are running 7.4.27
and if I force to switch to php8, and I try to run any CLI commands like php artisan or composer in the older application that requires PHP7.4, then I get the same error in reverse.
Edit: I didn't see the last of the comment saying the php74 command exists. it works now! Thank you!
@tykus One last question, when using the terminal, it seems to be behaving weirdly in that every time I close the terminal or open a new terminal, I have to run the export PATH=$home/bin:$PATH command again, otherwise it says that php74 command is not found. I'm not sure what I need to do to make that export path part permanent.
I realized that MacOS uses zsh which is different than bash, I used this thread to make the edits and now the paths that I added are added to my zsh profile.