John Davidson

How to avoid the preinstalled PHP on MacOS Big sur?

0 comments
Message:


I've installed an updated version of PHP 7.4 using homebrew.


But still, when i run php -v on the command line, i get :


WARNING: PHP is not recommended
PHP is included in macOS for compatibility with legacy software.
Future versions of macOS will not include PHP.
PHP 7.3.24-(to be removed in future macOS) (cli) (built: Dec 21 2020 21:33:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.24, Copyright (c) 1998-2018 Zend Technologies

As you can see, it's still using the one that comes with Mac Os.


When i run phpinfo from a php script, i can see it's using the correct one, as i configured on Apache, as shown below.


What i need to do to make the command line use the brew installed version of PHP ?




My Answer:
To avoid using the preinstalled PHP on MacOS Big Sur and make the command line use the version installed via Homebrew, you can follow these steps:

1. Update your PATH environment variable to prioritize the Homebrew PHP installation over the system PHP installation. You can do this by adding the following line to your shell configuration file (e.g., ~/.bash_profile, ~/.zshrc, or ~/.bashrc):

bash
export PATH="/usr/local/opt/php@7.4/bin:$PATH"


2. Source the shell configuration file to apply the changes:

bash
source ~/.bash_profile


3. Verify that the Homebrew PHP installation is now being used by running:

bash
php -v


You should see the version of PHP installed via Homebrew displayed in the output.

By updating your PATH environment variable to prioritize the Homebrew PHP installation, you ensure that the command line uses the correct version of PHP that you have installed.

Rate this post

5 of 5 based on 1635 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us