Make MacPorts PHP 7.3 run on OSX Mojave

84 views Asked by At

I am struggling with linking the newly installed PHP version on macOS Mojave (10.14.6)

I've installed PHP 7.3 via MacPorts (I need that exact version right now, I might update it later). Installation went alright, no errors.

When I run php -v it gives me

PHP 7.1.33 (cli) (built: Jan 26 2020 22:52:32) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

which, I suppose, is the version shipped with the OS.

My .bash_profile looks like this

PATH=/usr/bin:/bin:/sbin:/opt/bin   
PATH=/usr/local/sbin:"$PATH"
PATH=/usr/local/bin:/usr/sbin:"$PATH"  
PATH=/opt/local/bin:/opt/local/sbin:"$PATH"
export PATH
export PATH=${PATH}:/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

When I run php73 -v it logs

PHP 7.3.33 (cli) (built: Feb 16 2023 20:14:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.33, Copyright (c) 1998-2018 Zend Technologies

MacPorts has installed the PHP 7.3 into /opt/local/bin.

So obviously, the php version in use by the OS doesn't know about PHP 7.3

Oh, and using homebrew is not really an option. I've just lost hours trying it to install php 8.2 and it failed with one lib or another, constantly claiming that my XCode command line tools are outdated (duh! – and I am not upgrading those as it would require updating the OS to the latest version which would in turn strain my MBP even further).

Any help is greatly appreciated.

1

There are 1 answers

0
Haren S On

Try the following:

sudo port select --set php php73

See here for more details.