How to update php in mac
The solutions above did not work for me on Big Sur I kept on getting: Show
To fix this I used the following steps: Step 1 | Tap into another repository of formulae
Step 2 | Install the desired PHP version
Other options are:
Step 3 | Link the PHP Version
Step 4 | Restart TerminalStep 5 | Check PHP version
You should now see the new version.
This also solved my issues with PHP syntax in Visual Studio Code. Photo by Caspar Rubin on Unsplash Using HomebrewFirst, make sure that your homebrew is up to datebrew update && brew upgrade If you didn’t have homebrew, install it right away! Using Brew Tap command allows Homebrew to tap into another repository of formula.
Checking php version using the following commands
To unlink the last version
For instance, your current php version is 5.5 To install the new version of php
If you need php 7.1 then check php version again
If everything looks fine then congratulation! you’ve finished the php updated. But If you find the following errors you need to run the following commands
check php version again
linked to the old version?So open you .profile or .bash_profile
Source your file with Using one line installcurl -s https://php-osx.liip.ch/install.sh | bash -s < Scout APM helps PHP developers pinpoint N+1 queries, memory leaks & more so you can troubleshoot fast & get back to coding faster. Start your free 14-day trial today. # Upgrading with HomebrewStart by making sure brew is up-to-date:
Next,
upgrade PHP. You can either use the built-in php recipe, but I recommend to use the # Normal upgrade
# Upgrade with shivammathur/homebrew-php
To switch between versions, use the following command:
You can read more in the repository. # Next stepsCheck the current version by running
Restart Nginx or Apache, if you're using Laravel Valet you can skip to the next section; you need some extra steps in order for the web server to properly work.
And make sure that your local web server also uses PHP 8.1 by visiting this script:
The version should show Noticed a tpyo? You can submit a PR to fix it. If you want to stay up to date about what's happening on this blog, you can follow me on Twitter or subscribe to my newsletter: # ValetIf you're using Laravel Valet, you should do the following steps to upgrade it:
You can use
# ExtensionsPHP extensions are installed using pecl. I personally use Redis and Xdebug. They can be installed like so:
You can run
You can search for other extensions using
Make sure to restart your web server after installing new packages:
Make sure all extensions are correctly installed and loaded by checking both your PHP webserver and CLI installs:
If extensions aren't properly loaded, there are two easy fixes. First, make sure the extensions
are added in the correct ini file. You can run
Now check the ini file:
Note that if you're testing installed extensions via the CLI, you don't need to restart nginx, apache or Valet when making changes to ini settings. The second thing you can do, if you're updating from an older PHP version which also used pecl to install extension; is to reinstall every extension individually.
# Last stepFinally you should test and upgrade your projects for PHP 8 compatibility. FootnotesThe Road to PHP 8.1 New in PHP 8.1 — A comprehensive list of all things new in PHP 8.1 PHP 8.1 benchmarks Enums in PHP 8.1 Readonly properties in PHP 8.1 New in initializers in PHP 8.1 Fibers with a grain of salt How do I upgrade PHP to 8.0 on Mac?Upgrading with Homebrew. Normal upgrade. brew upgrade php.. Upgrade with shivammathur/homebrew-php. brew tap shivammathur/php brew install shivammathur/php/[email protected]. To switch between versions, use the following command: brew link --overwrite --force [email protected]. ... . Next steps. Check the current version by running php -v : php -v.. How do I update PHP to 7.4 on Mac?6 Answers. brew install [email protected].. brew link --force --overwrite [email protected].. brew services start [email protected].. export PATH="/usr/local/opt/[email protected]/bin:$PATH". export PATH="/usr/local/opt/[email protected]/sbin:$PATH". How do I update my version of PHP?How do I change the PHP version?. Log in to your one.com control panel.. Scroll down to the Advanced settings tile and select PHP and database settings.. Scroll down to Update PHP version.. Select the PHP version you want to switch to and click Update.. How do I check my PHP version on Mac?2 Answers. Go to File > Preferences > User Settings > Settings.json.. Change the value of php. validate. executablePath according to the installed directory of php7. "php.validate.executablePath": "/Applications/MAMP/bin/php/php7.0.14/bin/php". Relaunch VM Code.. |