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?
Related
MacOS 12.1 After successfully installing php 8.1 with homebrew (along with apache/mySQL and phpmyadmin) I am trying unsuccessfully to install/link php 7.4. After following instructions to install, unlink, link, php -v returns 7.4 but phpinfo() shows 8.1. What am I doing wrong?
Strange enough, using a full name such as "shivammathur/php/php#8.1" for the link command is what worked for me.
Eg:
brew link --overwrite --force shivammathur/php/php#7.4
Also, don't forget to close your terminal completely and reopen it before checking the version with php -v.
It looks as if I never successfully killed the included MacOS Apache. I uninstalled home-brew and the server was still running (with PHP8.1!). Not sure what went wrong.
I have uninstalled XAMPP because recently I found that php comes install by default in macOS. My MacOs version is Catalina. So whenever I fire any php command from cli it gives me Library not loaded but strange thing is it returns XAMP path.
I just now bought new Macbook Pro for development purpose. I did a small research and install MAMP on Mojave OS for my current project but happen to see my PHP CLI version is 7.1.23 and was unable to upgrade, coming from Windows background I have a lot of experience in XAMPP. I found the MAC OS installer and did my in installation with latest version of PHP available. As I wanted latest PHP for my project.
Now when I see phpinfo(); through my XAMPP localhot I can see PHP version 7.3 but when I go to terminal I see the same old version. I tried updating the PHP using this link but no luck in updating PHP CLI version.
And in CLI
Help me out with this. Thanks.
Run this command:
alias php='/Applications/MAMP/bin/php/php7.2.7/bin/php'
and replace 7.2.7 with your version number.
This will only work until you restart the terminal, in order to keep this change when re-opening the terminal you need to do the following:
Open ~/.bash_profile with a text editor of your choice (eg. nano)
nano ~/.bash_profile
Go down to the bottom and add the line from earlier.
Add alias php='/Applications/MAMP/bin/php/php7.2.7/bin/php' to the bottom of the file. Of course you can replace 7.2.7 with the version of your choice.
Similarly we can do it for XAMPP, like this:
export XAMPP_HOME=/Applications/XAMPP
export PATH=${XAMPP_HOME}/bin:${PATH}
export PATH
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.
If I run "phpbrew switch 5.6.3" followed by "php -v", i get 5.9.3 (PHP System Version) as current PHP Version.
If I run phpbrew "use 5.6.3", i also get 5.6.3 with php -v.
Is there any solution for this problem? PHP version 5.6.3 is installed and built with phpbrew and working after using the use command.
I am using Elementary OS Freya (Ubuntu 14.04) with the latest phpbrew version.
If you are getting a red error line "You should not see this, if you see this, it means you didn't load the ~/.phpbrew/bashrc script, please check if bashrc is sourced in your shell.", then you need to run source ~/.phpbrew/bashrc. It's also a good idea to run echo "source $HOME/.phpbrew/bashrc" >> ~/.bashrc, so that in the future this will be automatic.