Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

garrettmassey's avatar

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.

0 likes
9 replies
tykus's avatar

What is not working for you whenever you try to symlink the PHP version?

garrettmassey's avatar

@tykus The example given in the Laravel News article is this:

ln -s $(brew --prefix [email protected])/bin/php $HOME/bin/php74

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's avatar
tykus
Best Answer
Level 104

@garrettmassey create the directory:

mkdir ~/bin

add it to your PATH in your .zshrc file (or .bashrc)

export PATH=$HOME/bin:$PATH

and make the symlink again:

ln -s $(brew --prefix [email protected])/bin/php $HOME/bin/php74

Now you will have a php74 command in the terminal, which is separate to your main linked php

1 like
garrettmassey's avatar

@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!

1 like
garrettmassey's avatar

I didn't see the last of the comment saying the php74 command exists. it works now!

garrettmassey's avatar

@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.

garrettmassey's avatar

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.

akhmami's avatar

i have the same problem, just run valet composer update or valet php artisan if you want to run artisan command

9 likes
deraafmedia's avatar

@akhmami Thanks. You saved me a lot of time with this. I actually think this should be marked as the best answer.

Please or to participate in this conversation.