My php version is PHP 7.4.1.
But with MAMP, the highest possible php version I can use is 7.3.8.
So, when I try to open my webpage, I get the error message:
Fatal Error: composer.lock was created for PHP version 7.4 or higher
but the current PHP version is 7.3.8.
How can I downgrade my php version to fit to my MAMP version?
I tried:
brew install php#7.3
It was installed, but when I now write php --version, I get the error:
-bash: /usr/local/bin/php: No such file or directory
you don't need brew's PHP if you want to use MAMP's PHP.
just use Applications/MAMP/bin/php7.3.8/bin/php --version to use MAMP PHP, if you want to use as default command line, just link it to /usr/bin.
to link it run this to your command line:
export MAMP_PHP=/Applications/MAMP/bin/php/php7.3.8/bin
export PATH="$MAMP_PHP:$PATH"
or
PHP_VERSION=`command ls /Applications/MAMP/bin/php/ | sort -n | tail -1`
export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH
check it out for more detail.
PS: Maybe you should delete your brew php to do it.
First
$ brew update
and
$ brew upgrade php
Related
I Have installed MAMP in my mac, Using the php version of 7.4.
command which php
returns - /Applications/MAMP/bin/php/php7.4.21/bin/php
I have installed php 8.1 using brew.
I comment the ~/.bash_profile
# export PATH=/Applications/MAMP/bin/php/php7.4.21/bin:$PATH
# alias mysql=/Applications/MAMP/Library/bin/mysql
# export PATH="/usr/local/opt/node#13/bin:$PATH"
but still its show the same php path . How to shift to newly installed php version?
You have to link which version of PHP you want to use.
brew unlink php will unlink the current version of PHP.
brew link php#8.1 will link with PHP 8.1 (you need to install it before)
I was given a macbook 2019 for work which has catalina 10.15.6 ... the default PHP is 7.3 .. can someone show me the step by step on how to avoid this default PHP version?. I found some tutorials online using homebrew in order to use multiple versions of PHP. but then am a bit skeptical to install the homebrew php yet, coz I scare it will conflict with the default PHP with the OSX . any idea ?
Homebrew manages the installation for you and updates the necessary paths.
With homebrew installed you can just run the following command to install php7.4
brew update
brew install php#7.4
Check your PHP version now
php -v
If it still prints out the old version, update your path:
echo 'export PATH="/usr/local/opt/php#7.4/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php#7.4/sbin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
Alternative one-line install
curl -s https://php-osx.liip.ch/install.sh | bash -s 7.4
To do that, Within the terminal, Fire this command:
which php
This should output the path to the default PHP install which comes preinstalled by Mac OS X, by default it has to be
Now, We just need to swap this over to the PHP that is installed with MAMP, which is located at /Applications/Xampp/bin/php/php7.3/bin for example
Within the Terminal, run vim ~/.bash_profile
Type i and then paste the following at the top of the file:
export PATH=/Applications/Xampp/bin/php/php7.3/bin:$PATH
Hit ESC, Type :wq, and hit Enter
In Terminal, run source ~/.bash_profile
In Terminal, type in which php again and look for the updated string. If everything was successful, It should output the new path to MAMP PHP install.
In case it doesn't output the correct path, try closing the terminal window (exit fully) and open again, it should apply the changes (Restart in short).
source : https://gist.github.com/irazasyed/5987693
I have been trying to enable PHP 7.1 iMap extension on MAC Mojave 10.14.5, but I haven't had any luck getting it to work. Any help will be greatly appreciated.
Before any installation, php -v returns 7.1.23 and which php returns /usr/bin/php since Mojave has PHP 7.1 preinstalled. However, php -m doesn't include iMap since the extension is not installed by default.
I have tried to tap with either kabel/php-ext or
v1shky/php-ext and brew install php#7.1-imap, got the following in the installation process:
The php.ini and php-fpm.ini file can be found in:
/usr/local/etc/php/7.1/
php#7.1 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have php#7.1 first in your PATH run:
echo 'export PATH="/usr/local/opt/php#7.1/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php#7.1/sbin:$PATH"' >> ~/.bash_profile
For compilers to find php#7.1 you may need to set:
export LDFLAGS="-L/usr/local/opt/php#7.1/lib"
export CPPFLAGS="-I/usr/local/opt/php#7.1/include"**
And when I check, php -v returns 7.1.30, which php returns /usr/local/bin/php and php -m still doesn't include iMap.
Then I followed the instruction to modify bash_profile, and now php -v returns 7.1.30 and which php returns /usr/local/opt/php#7.1/bin/php. However, php -m still doesn't include iMap.
Is there a better way to add the iMap extension for the existing PHP 7.1 that comes with Mojave? If not, is there anything else I should do when using HomeBrew so that it would work?
By the way, I have to stay on PHP 7.1 instead of upgrading to 7.2 or 7.3 due to some other frameworks we are using.
Thanks in advance!
I am developing a PHP project. I am using Mac OS X now. To be honest, this is the first time developing a PHP project using Mac. I am a Windows. I installed PHP using Brew by running the following command.
brew install php
It gave me the php latest version, 7+. For my project, I need to use php version 5.6. So, I installed another PHP by running this command.
brew install php56
Up until this point when I enter "php --version" in the terminal, it is showing that I am using php version 7+. I found some solution to change php version and so I used one of them and run this command.
alias php='/usr/local/etc/php/5.6/php'
After running that command, when I type in "php --version" in the terminal, it is showing this error.
-bash: /usr/local/etc/php/5.6/php: No such file or directory
Now, I cannot use any PHP on my Mac right now. How can I fix that?
I am quite new to CentOS.
On my CentOS web server I have PHP 5.4.16 as a native PHP version though I also have alternate PHP version 7.0.
I am trying to install xDebug for PHP 7.0 following the instruction on https://xdebug.org and one of the steps is to run
./configure
When I run ./configure command I am getting error message:
not supported. Need a PHP version >= 5.5.0 and < 7.2.0 (found 5.4.16)
So my question is how do I tell ./configure to use alternate PHP version 7.0?
If you run php -v on command line, it will output the version of PHP it is currently on your PATH. My guess is that it will return the older version of PHP as the result.
The quick and dirty way to try and get it to use version 7.0 for your current shell session would be to run the following
set PATH="/your/path/to/php7/bin:$PATH"
php -v
//Should output version 7.0
You could also try checking in /usr/bin or /usr/local/bin to see exactly which PHP binary it's pointing to, and manually change the location that the symlinks are pointing to.
Another option would be to try creating an alias in your ~/.bashrc file for PHP by editing the file and adding the following to the end:
alias php="/your/path/to/php/7/bin/php"
Then restart your shell session (i.e. close an & re-open PuTTY or whichever SSH client you're using).
Now type php -v and you should see it change to version 7.0.