Make MacPorts PHP 7.3 run on OSX Mojave - php

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.

Related

Error to use terminal commands on PHP with Mac OS MAMP

I'm using MAMP 6.5 - Build 33813 (Macbook Air M1 2020) to make some Apache hosts.
All everything is ok, except one thing. I can't use terminal commands on my PHP code (exec, copy, and others).
I uninstalled my Brew PHP and using only MAMP PHP 7.2 and 8.0 (CGI).
I receive no errors or logs, just doesn't work. This is my terminal's response when I run php -v:
PHP 7.2.34 (cli) (built: Aug 5 2021 15:20:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Image - PHP MAMP Config

Why am I still getting the Php warning on mac after I made sure to install brew install php?

When I typed in php -v, I still get this warning:
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
So I ran brew install php and then tried again with php -v but I'm still getting this warning.
What should I do? I need to install composer after this...
After installing the brew install PHP just restart the terminal

Laravel 5.4 with MongoDB MAC Mojave

Hello I having trouble to to install "jenssegers/mongodb": "^3.2" on my local environment.
i have this error:
I have added to my /etc/php.ini full path to extentions="/usr/lib/php/extensions/no-debug-non-zts-20160303/mongodb.so"
restart the php and apache
I have try to find mongodb.ini, fail on that.
I try all the tutorial is google... still no luck
Can any one help me please?
PHP 7.1.23 (cli) (built: Feb 22 2019 22:08:13) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
It seems that you forgot to install MongoDB PHP Driver itself.
To do that just install it with pecl:
sudo pecl install mongodb-1.5.3
1.5.3 is the last stable version, so I'd recommend to use it rather than the most recent 1.6.0alpha.
Then, don't forget to add it to your php.ini (run php --ini to see where it's located):
extension=mongodb.so
To test that it works just run:
php -m | grep mongo
If you see mongodb in output, then it works.

Downgrade from default PHP 7.1 to PHP 7 on macOS High Sierra

I have a fresh installation of macOS High Sierra which comes with PHP 7.1.16 (Build date: Mar 31 2018 02:53:20) installed. I would like to downgrade this to PHP 7.0.27.
PHP 7.1.16 wasn't installed with homebrew, so I assume it's not as easy as removing it and installing PHP 7 with brew.
What is the best and safest way to do this?
There's many resources to upgrade from PHP 7 -> 7.1 or 7 -> 7.2, but nothing to go the other way on macOS.
PHP 7.1.16 (cli) (built: Mar 31 2018 02:59:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
The best solution as far for my purposes was the shell tool "update-alternatives".
With that you should be able to switch between diffrent php versions dependently on your project.
So for example to switch to anohher php version set:
update-alternatives --set php=path to your php

Set default version of Php in CentOS 7

I have two versions of PHP in opt/remi folder php56 and php72
but when I php -v on cmd it shows:
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans
How to set default version to PHP 7.2?
I have two versions of PHP in opt/remi folder php56 and php72
how to set default version to PHP 7.2
SCL are designed for parallel installation so don't alter default version in base system
Once the collection is enabled, the version will be used
$ scl enable php72 bash
$ php -v
PHP 7.2.8 (cli) (built: Jul 17 2018 05:35:43) ( NTS )
If you want 7.2 to be the default version (base system) you should install it, according to Wizard instructions for "Default / single version" (and keep 5.6 as secondary version)
Change php cli version in Centos 7
First, find your php7, run phpinfo() and get path or you can do with other ways. for me, it is:
/usr/local/lsws/lsphp73/
then:
cd ~
. ~/.bash_profile
And:
alias php='/usr/local/lsws/lsphp73/bin/php'
Now:
php -v
PHP 7.3.13 (cli) (built: Dec 20 2019 16:02:35) ( NTS )
Create a file "/etc/profile.d/php.sh". Use pathmunge to add the path to your php bin you want as default on line one and save the file.
Example:
pathmunge /opt/remi/php73/root/bin
Reload your profile afterwards by logging in again.
Now if you do a which php and php -v you should see the following output in my case
[root#host etc]# which php
/opt/remi/php73/root/bin/php
[root#host etc]# php -v
PHP 7.3.4 (cli) (built: Apr 2 2019 13:48:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.4, Copyright (c) 1998-2018 Zend Technologies
with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v10.3.4, Copyright (c) 2002-2019, by ionCube Ltd.
This is the preferred way to accomplish this task using tools that are already supplied on a minimal install. This also allows scripts and commands to hit the correct php binaries when accomplishing other tasks. Commands like, pear, pecl, phar, php-config. You want your experience to be global when setting the default, otherwise you might wind up still getting version 5.6's tools when trying to install an extension or complete another task.
module enable php74
for your understanding:
cat /opt/remi/php74/enable
export PATH=/opt/remi/php74/root/usr/bin:/opt/remi/php74/root/usr/sbin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/opt/remi/php74/root/usr/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export MANPATH=/opt/remi/php74/root/usr/share/man:${MANPATH}

Categories