I'm using Mac OS X (10.11.6) with MAMP PRO 3 and PHP 5.6.10. I've setup the PATH in .bash_profile and everything looks fine.
When I do which php in the terminal I get the following correct path:
/Applications/MAMP/bin/php/php5.6.10/bin/php
Now I'm trying to execute an exec-command with PHP along the lines of the following example:
exec('which php');
This returns /usr/bin/php and therefore is wrong, I want it to use the other version too.
My MAMP related things from .bash_profile:
export PATH=/Applications/MAMP/bin/php/php5.6.10/bin:$PATH
export PATH=/Applications/MAMP/Library/bin/:$PATH
What am I missing?
Related
I have created a .bash_profile in my home and now it contains the following two lines:
export MAMP_PHP=/Application/MAMP/bin/php/php7.2.7/bin
export PATH="$MAMP_PHP:$PATH"
But the php -v command in the terminal still shows a different version to MAMP. I already restarted both the terminal and MAMP as well.
Any idea?
I have mac os sierra machine. When I start a php project in vs code, I get the following warning
language server needs php 7, and the version found is 5.6.27.
So I used homebrew to upgrade to version 7 and confirmed it from the terminal. I am also running mamp which show version 7.
But in the terminal of vs code the php version is still 5.6.27. So I am bit confused?
I changed the value of php.validate.executablepath in settings.json in vs code from usr/bin/php to usr/local/bin/php, but still vs code terminal showing the older version (viz. 5.6.27)
This is because VM Code still checking /usr/bin/php directory which is php5
You have to configure the path to the PHP executable in the user settings file.
Follow the following steps to change it
Go to File > Preferences > User Settings > Settings.json
Change the value of php.validate.executablePath according to the installed
directory of php7.
"php.validate.executablePath":
"/Applications/MAMP/bin/php/php7.0.14/bin/php"
Relaunch VM Code
If the problem remains same, then add the path to PHP7 to your environment variables, run where php and php --version to verify. To add path in your macos sierra do the following:
Within the Terminal, run vim ~/.bash_profile
Type i and then paste the following at the top of the file:
export PATH=/user/local/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 went 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)
To find out what version you're using, upload a php file to your server containing the following code...
<?php
phpinfo();
?>
It will tell you at the top of the page.
I just installed Composer on OS X 10.8 and am now trying to use it to install something else and it turns out my terminal is running php 5.3... In XAMPP I have 5.5, so I would like to just use that version in Terminal as well. I tried creating a .bash_profile in my home directory with
export PATH=/Applications/XAMPP/xamppfiles/bin/php-5.5.11/bin:$PATH
but that wouldn't work; which php still returns /usr/bin/php. What am I missing here? Much thanks in advance.
Here is my working Environment Path
export PATH="/Applications/XAMPP/xamppfiles/bin:$HOME/.composer/vendor/bin:/usr/local/sbin:$PATH"
Remember to wrap the path with double quotes and also close all terminal before checking the php version using
php -v or which php
If you aren't using a bash shell, then changing the bash_profile won't make a difference. bash apparently wasn't always the default, so on my mac, I am using .tcsh. I don't know why it uses one over the other, it has just always been that way (been upgrading macs since OS X 10.0). So on mine I have a .tcshrc file which operates like the bash_profile. In there I have
alias php /Applications/MAMP/bin/php/php5.6.7/bin/php
which you would obviously have to adjust to your own path and version, but you get the point.
I want to use MAMP on my OSX box as I am learning Laravel development.
I have added the following line to ~/.bash_profile:
export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH
I restarted terminal, restarted MAMP, but when I run which php the result is still /usr/bin/php.
Any tips? Thanks!
Your path can be changed, while the default OS response to the which command remains unchanged.
Example:
which php
/usr/bin/php
php
bash: Applications/MAMP/bin/php: No such file or directory
Run this command:
echo "$PATH"
[NOT a complete answer]
Last night I upgraded to PHP 5.5.3 using http://php-osx.liip.ch/ on my new Macbook. I have OS X v10.8.5
Each time on launch terminal or iTerm, I have to put PATH=/usr/local/php5/bin:$PATH into the terminal to get it to properly set the path. Why?
I did put the same path into ~/.bash_profile and ~/.profile.
Running phpinfo in the browser, without touching terminal, does show PHP 5.5.3.
Open terminal and type:
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.5
5.5 is a PHP version (if you want install a specific version), then check if it works:
php -v
In ~/.bash_profile add export PATH=/usr/local/php5/bin:$PATH
My ~/.profile is currently empty.
Now in terminal do
source ~/.bash_profile
Try php -v.
I've restarted terminal a few times with the correct results. Both phpinfo() and terminal php -v show PHP 5.5.4.
Hope this helps.