How to update the version of PHP that I have installed on the Mac to PHP 8

To update PHP to version 8 on MacOS try the following commands:

brew update

And then:

brew upgrade php

If it doesn’t work for you, you may not have it installed on your Mac, I recommend it.

If what comes out is Error: php not installed then you will have to install PHP.

brew install php

Normally it will install the latest version of PHP, but you can tell it which version you want with:

brew install php@8.0

Or a more modern version:

brew install php@8.1

If you come from an older version of PHP, it is possible that even if you install PHP 8, version 7.x will still run on your machine. To set the version of PHP you want to run you can run this command.

brew link –force php@8.0

To restart PHP

brew services restart php@8.0

If you still can’t get your php to update in the CLI (command line terminal) check if you have any older PHP installation taking precedence. You can try to see if in the PATH you have any PHP route that is declared and therefore is being executed.

On modern MacOS you may have modified the PATH in the .zshrc file that is in your user’s folder.

you can also do

which php

To find out where the PHP executable that is being used is… to see if it corresponds to the path that it should.

I get this output:

/usr/local/bin/php

If you go to the /usr/local/bin folder you can see the symlink you have to your PHP file running in the CLI. I get this:

See also  CSS height: 100% - Layer height that is the same as the browser window

php -> ../Cellar/php/8.1.4/bin/php

That symlink makes php 8.1.4 run. You change it with the command I mentioned before:

brew link –force php

But you can also do it by hand with this help for .

Loading Facebook Comments ...
Loading Disqus Comments ...