i've updated my MACOSX 10.6 and since then, i've not been able to use the PHP console version from MAMP.
php -v returns me 5.3.3 which is the PHP i've compiled and i want to use the one from MAMP
I've already done :
export PATH=$PATH:/Applications/MAMP/bin/php5.3/bin
and creating a .bash_profile and a .profile fileand i put in it : /Applications/MAMP/bin/php5.3/bin
without any results
echo $PATH returns :
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin
Did you reload the profile after altering .bash_profile?
source ~/.bash_profile
(or .profile if you use that one)
Related
Hello and thank you for taking your time to read this! Now to get straight to the point, I am using MAMP PRO 6 for school and recently we had to install Composer through the terminal. Upon closer inspection php -v revealed that I am not using the MAMP's php version with Xdebug but rather the pre-installed php version that comes with macOS. I have enabled Activate command line shortcuts for the selected PHP version, pear & pecl but this is not working. I'm on the latest Big Sur update and looking for a possible fix.
MAMP PRO is working with the exception of command line shortcut.
Depending on the shell you use (bash, zsh, check your OS) just add "source ~/.profile" to your bash, zsh-or other profile. MAMP PRO 6 recreates the .profile when changing php versions.
Check the "composer"-link in the UI and everything should work just fine. Don't forget to start a new terminal session though. Otherwise the old configuration (with the old php and more) stays active.
~/.profile is not being read. You have to define a ~/.bash_profile, ~/.zshrc or something. In that profile that is read by the shell you put the "source"-statement.
The issue is that my .profile is not being loaded automatically , current workaround is doing source ~/.profile and then confirming the location and version with which php and php -v.
Update: This did it for me https://stackoverflow.com/a/56236178/14612433
I tried to make the xampp php version as a default php instance. At the moment the build in php version is default. In the nano .bash_profile I write the statement
export PATH=/Applications/XAMPP/xamppfiles/bin:$PATH
and this is no stored in the bash_profil. But when I check the php version via php -v I get the older one. Any idea?
exec "$SHELL" to load your recently changed .bash_profile. That should do it.
When I run php -v in cli I get the exact php version 7, but when i run exec("php -v") in web server I get php 5.5 even thought in phpinfo i see that I am runing php 7?! Any idea why I get the older version of PHP?
running exec you get the CLI version of PHP
you probably installed php5.5 as CLI and php7 as apache module
If you use CentOs, add this line at the end of /etc/bashrc (or ~/.profile for Ubuntu)
export PATH=$PATH:/your/path/to/php7/bin
Then run:
source /etc/bashrc
P/s It may be better if you edit /etc/profile.d. Take a look both of them.
UPDATE
In MacOS, let edit ~/.bash_profile (create it if it does not exist) with the same content.
I've updated PHP from 5.5.34 which was installed on my Mac to PHP 5.6.25 using this guide: https://coolestguidesontheplanet.com/upgrade-php-on-osx
When I upload a phpinfo() script it's showing that I'm using PHP Version 5.6.25 which is what I'm expecting.
However, in Terminal it's seeing the old version of PHP:
$ php -v
PHP 5.5.34 (cli) (built: Apr 22 2016 19:16:58)
How can I get the Terminal to use the updated version of PHP?
As usual nobody answered, but I figured it out so posting the solution...
If you follow that guide you will need to do the following:
sudo apachectl restart
That should get the correct PHP version (7.x if you follow the link right the way through to the end) working in your browser. But your Terminal will still display 5.x
In your home directory create a .bash_profile file:
cd ~
nano .bash_profile
and put this in it:
export PATH=/usr/local/php5/bin:$PATH
Save the file and exit.
Load the .bash_profile:
source .bash_profile
Now when you do php -v you should see it reporting 7.x. So it's using that in your Terminal and browser; all good.
The installer works in a strange way whereby even though you're using PHP 7.x it will put it in a directory called 'php5' (/usr/local/php5) but this is a symbolic link to a different directory.
I'm trying to install a package via Composer that requires PHP 5.6.0. My MAC is running PHP 5.5.31 but MAMP runs PHP 7.0. The package will not download because of the PHP requirement is not met since it's looking at my macOS version, not the version I actually use with MAMP. How can I get around this?
MAMP's PHP is located here:
/Applications/MAMP/bin/php/php7x.x/bin/
The default OSX PHP is located in
/usr/bin/php
/usr/bin is in PATH variable by default.
When you want OSX to use the MAMP version instead, you need to add /Applications/MAMP/bin/php/php7.x.x/bin/ to your PATH variable.
Simply edit ~/.bash_profile in your terminal and type
vim ~/.bash_profile
if you cannot find ~/.bash_profile then you have to create one with
touch ~/.bash_profile
and add the following line to end of the file:
export PATH=/Applications/MAMP/bin/php/php7.x.x/bin/:$PATH
You just have to look at the correct version of your MAMP's php and replace the x.x from the example above with that correct number. (e.g. 7.0.2)
If that went fine, relaunch your terminal.app and do php -vagain. Now you have to see the new version.
After that try to install the composer package again! Good luck
Help source: how-to-override-the-path-of-php-to-use-the-mamp-path
This was easy to me:
First backup system php sudo mv /usr/bin/php /usr/bin/~php
Then crate a symbolic link from /Applications/MAMP/bin/php/phpX.x.x/bin/php to /usr/bin/php using this: sudo ln -s /Applications/MAMP/bin/php/phpX.x.x/bin/php /usr/bin/php. Now you have your mamp php (with its config) available everywhere.
If you type 'which php' into Terminal it'll show you where it's looking for PHP. I'm guessing there are 2 different versions of PHP installed into different directories. In which case you might be able to use a bash script to set the correct path to the PHP version you want?
I've had similar issues on my Mac where I've installed software like git, but it's looking elsewhere for it (e.g. the version bundled with Xcode)