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

connecteev's avatar

Cant upgrade php version on MacOS Catalina

I have a very annoying problem. I have 2 versions of PHP on MacOS Catalina, and no matter what I do, I cant seem to get rid of the old (php 7.3.x) version. I can't change anything in /usr/bin/ on my Mac, even though I'm an admin user.

The 2 versions of PHP are:

$ /usr/bin/php -v
PHP 7.3.11 (cli) (built: Apr 17 2020 19:14:14) ( NTS )
$ /usr/local/bin/php -v
PHP 7.4.9 (cli) (built: Aug  7 2020 19:23:06) ( NTS )

Even though which php and php -v use 7.4:

$ which php
/usr/local/bin/php
$ php -v
PHP 7.4.9 (cli) (built: Aug  7 2020 19:23:06) ( NTS )

The problem is that when my cron job runs, it uses /usr/bin/php (version 7.3.x), making my cron job fail (turns out some Laravel package code - specifically Mailcoach - is not compiant with php 7.3.* and NEEDS php v 7.4 or above.

This is what my PATH variable looks like:

$ echo $PATH
/usr/local/bin/php:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:./vendor/bin:/usr/local/sbin:/Users/kunalpunjabi/.composer/vendor/bin:/usr/local/mysql/bin:/usr/local/bin/mysql

If you've encountered this before or know how to fix it, please help!

0 likes
9 replies
bugsysha's avatar

Try Laravel Valet, it can manage PHP versions and switch between them.

Snapey's avatar

i always specify the path to php in my crontab

tykus's avatar

i always specify the path to php in my crontab

This 👆

connecteev's avatar

@bugsysha I want to use php locally (instead of homestead or valet) - i dont want to deal with VMs, port forwarding, and all that

@snapey @tykus good point yeah, and that works, but I'd like to just run "php" and not have to worry about version differences and being bitten by this issue again. Hope that makes sense.

@tisuchi I did try the approach at http://laravel-school.com/posts/macbook-update-php-version-globally-35 but it didnt work for me. My cron job still invokes /usr/bin/php which has version 7.3.

@tray2 that didnt work either.

rafaelmelope's avatar

Try to do a smbolic link /usr/bin/php to /usr/local/bin/php

ln -s /usr/bin/php /usr/local/bin/php

connecteev's avatar

@rafaelmelope

/usr/local/bin/php is a logical link to /usr/local/Cellar/php/7.4.9/bin/php

so I think you meant this:

sudo ln -s /usr/local/Cellar/php/7.4.9/bin/php /usr/bin/php

Unfortunately Catalina's system integrity protection wont let me do that.

$ sudo ln -s /usr/local/Cellar/php/7.4.9/bin/php /usr/bin/php
Password:
ln: /usr/bin/php: Operation not permitted

Ready to hang in the towel on this one - was really hoping for a way to fix the php version in /usr/bin/php, but Apple makes it really difficult.

Please or to participate in this conversation.