DEV Community

Cover image for Upgrade to PHP 8.x.0-dev with Homebrew on Mac
Sesha
Sesha

Posted on

Upgrade to PHP 8.x.0-dev with Homebrew on Mac

Now, PHP 8.0.0 Release Candidate 4 available for testing, It's expected to release on November 26, 2020, It's a new major version, and a lot of improvements and new features.

Here, step by step process to install PHP 8.0.0-dev with Homebrew on Mac.

Make sure brew up to date with the following command

  brew update
Enter fullscreen mode Exit fullscreen mode

At the time of writing this article, brew doesn't support php8, So we install using this git repo

Add the tap

Fetch the formulae in this tap.

brew tap shivammathur/php
Enter fullscreen mode Exit fullscreen mode

Install PHP 8.0

brew install shivammathur/php/php@8.0
Enter fullscreen mode Exit fullscreen mode

and finally, link with PHP 8.0

brew link --overwrite --force php@7.3
Enter fullscreen mode Exit fullscreen mode

Check the current version by running PHP -v:

PHP -v
Enter fullscreen mode Exit fullscreen mode

And restart the Restart Nginx or Apache:

sudo nginx -s reload

//or 

sudo apachectl restart

Enter fullscreen mode Exit fullscreen mode

And also you check your local web server using the current version by running the following script.

// create index.php file, this should be accessible to your web server

phpinfo(); die();
Enter fullscreen mode Exit fullscreen mode

Switching between versions.

If you want to switch back to PHP 7.4, here you can do that.

Unlink the current version like this

brew unlink PHP
Enter fullscreen mode Exit fullscreen mode

and link to PHP 7.4

 brew link --overwrite --force php@7.4
Enter fullscreen mode Exit fullscreen mode

if you want to link to PHP 7.3

 brew link --overwrite --force php@7.3
Enter fullscreen mode Exit fullscreen mode

If you like, please like and follow me to do more like this. Thank you!.

Oldest comments (1)

Collapse
 
leslieeeee profile image
Leslie

For PHP users, there is a tool called ServBay.dev that provides a much easier way, especially for beginners. It handles all versions of PHP, MariaDB, PostgreSQL, as well as Redis and Memcached. You can run multiple PHP instances simultaneously and switch between them effortlessly, without the need for any environment setup. This tool has simplified my PHP development and is definitely worth a try!