MacOS delete php 5.6 and leave only php 7 - php

I have 2 versions of php installed on my macOS. When I restart the computer it is set by default to php 5.6 (I have already twice installed php 7 and it is available only till the next restart). How can I set the default to be 7.0? what should I do in .bash_profile? (to what should I change the home path of the php variable?)

If you install PHP with Homebrew, you might need to unlink the 5.6 version. Like:
$ brew unlink php56
Then you may start to install PHP 7.2
You can get more information from my article:
Upgrade PHP version from 5.6 to 7.2 on macOS Sierra (10.12)

Related

Why xdebug.so is not in php 8 folder when installing from homebrew?

So I installed php 8 with homebrew and I got the PHP 8 installation folder. However, I am trying to connect xdebug with phpstorm. So when I got to the step of linking the 'zend_extension=' path, the PHP 8.0.1 folder didn't contain xdebug.so(I've looked and searched everywhere it doesn’t exist), I have other versions of PHP like 7.3 and 7.4, and they have xdebug within them maybe its cause I didn't use homebrew to install the 7.3 and 7.4 versions or maybe something else I don't know. I've tried deleting version PHP 8 and installing it again but that won't give me the extensions folder which contains xdebug.so, so I can add that path to the 'zend_extension='
The Xdebug extension is not automatically installed by homebrew by default, but you can easily install it using pecl:
$ cd /usr/local/Cellar/php/8.0.10/bin
$ ./pecl install xdebug

PHP CLI on Apple M1 using Homebrew

I've followed this guide to install Homebrew on an M1 based Mac.
After that I ran
brew install php#7.4
which installed PHP successfully.
If I now run
brew upgrade php
I get
Error: php not installed
What I like to achieve is to update the PHP that comes shipped with macOS, which is 7.3.22 when I run php -v.
How can I update PHP using Homebrew? I understood that I need to put something in my PATH to point to the newer PHP version? Given this is a new machine I actually don't have a .bash_profile file, only a .zshrc (I'm using ZSH, I assume that this file will be used and that I don't need a .bash_profile?)
It's not advisable to upgrade the system-provided PHP, but it's also not necessary.
brew link can be used to decide which PHP is utilized. brew link php#7.4 should do the trick; this can be also used to switch PHP versions around, i.e. brew link php#8.0 will switch you over to that while leaving both versions installed and available directly.

macOS 10.13 Server app v5.6 PHP Downgrade From 7 to 5

Has anybody been able to successfully downgrade the php version preinstalled with the macOS High Sierra server app?
Preinstalled PHP version is 7 but I'm running some old PHP apps that require PHP version 5.
I can't find any recent answers on the topic.
Can anybody help?
I do not recommend downgrading the version, I would install PHP 5.6 using homebrew and then just having both versions installed.
brew install php56
This will be symlinked from /usr/local/Cellar/php56 into /usr/local/bin and as long as this in in your $PATH then you should be able to use PHP 5.6 without overriding 7

How to install PHP5.6 on OSX High Sierra without homebrew or macports

I have upgraded from OSX Sierra to HighSierra which comes with Apache 2.4 and PHP 7.1 out of the box. For development I need to be able to use PHP 5.6 but have had issues with trying to run Homebrew (both with system Apache and Brew apache) and also phpbrew.
I also built PHP5.6 from source but think I need some additional steps to allow it to run alongside PHP7.1 as I ended up with the CLI version as 5.6 and the browser version as 7.1.
I have since removed the homebrew packages, and am back up and running with PHP 7.1.
So my question is - how can I install PHP5.6, without homebrew or macports and be able to switch between PHP versions either per-site, or globally?

Install php 7 on mac with Homebrew

Hi just got a new fresh mac and I want to use the last version of php7.
So I have instal php 7.1 with homebrew successfully. But the php -v command show that I have the 5.6 version witch is the default version installed on mac.
How can I target the new version of php installed with homebrew.
I have followed this tutorial to do it : https://developerjack.com/blog/2016/installing-php71-with-homebrew/
You need to set your PATH environment variable to have /usr/local/bin at the start because that is where homebrew puts your installed binaries:
export PATH=/usr/local/bin:$PATH
Put that in your login profile too, so it works on future logins.
You may also need to rehash with:
hash -r
which causes your shell to forget where commands are, so it has to search afresh.

Categories