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
Related
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
I'm trying to install PHP 7.0, which works. But when I check my php -v in the cmd, it still says 5.5.36.
I tried it via php-liip, homebrew, install manually and via cmd. Nothing works. When I change version of PHP in MAMP (which I work with to try and install composer in a directory, that I need PHP 5.6 or higher for) i still doesn't matter.
The PHP 5.5 you're seeing was installed by Apple and is a default on your computer. It was installed at /usr/bin/php.
All of the installers you've used will not overwrite Apple's default installation - they will instead opt to create their own directories or use /usr/local/bin/ instead (thus the PHP interrupter would be installed at /usr/local/bin/php). In other words, you almost certainly have multiple php's ready to use right now. The next thing you need to do is tell bash (the default terminal/cmd on a Mac) to use the newly installed PHP interrupter.
When you run $ php on your command line, bash checks for an executable file on each of paths stored in the PATH environment variable. Once it finds one, it decides that that executable is the one you're looking for and runs that program. As of now, it's finding Apple's PHP 5.5 before it finds your fresh install of PHP 7.0 - assuming it finds PHP 7.0 at all.
You can fix this by updating PATH to check wherever PHP 7 is installed first. Instructions to do so can be found on SuperUser.StackExchange:
How should I set the PATH variable on my Mac so the Homebrew-installed tools are found?
To change php version in Ubuntu, try to use this comand
sudo update-alternatives --config php
and then select version what you need
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)
hey guys I need your help for setting environment for zendframe work ? I have installed my netbeans in D: drive under D:/program files/netbeans. and the zend framework is under D: drive. and my wamp package is installed under c:/wamp. now what i need is to configure these all for my development?
I searched google, stackoverflow and every blog i could for the whole day. but all that I got is a error given below.
'"php.exe"' is not recognized as an internal or external command,
operable program or batch file.
tell me how can I solve this ? what should I do ? Do I need to set all these under one roof or I need to upgrade my PHP version ???
Yes My config is written below.
WAMP Server 2.0c with PHP 5.2.6, MySQL 5.0.51b, Apache 2.2.8.
Netbeans 7.1.1 and Zend framework 1.11.11
Add php.exe to your environment variable PATH. If you add the directory where php.exe is installed to your PATH environment variable (you may need to log out for it to take effect), it should work.
See this tutorial
You may actually specify the path to PHP interpreter within Netbeans, in Options - PHP - General tab.
Perhaps you should set up the include_path as well to make Zend modules (at least autoloading one) recognizable.
Update to a more up-to-date version of PHP first.
Then, ensure that PHP is on your environment PATH variable. You can look up on google how to do that.
You'll have to install phpunit too after you get that setup. WAMP might come with it but I doubt it. Usually this is easy if you have pear. You can get the pear commands from the phpunit site.
If you don't have pear you'll have to install that. Download a 'go-pear.phar' file that is appropriate to you. You usually install it by running php go-pear.phar' and then you can use pear it install phpunit.
You can then call it a day OR you can continue setting up Netbeans to automatically use phpunit.
If you don't setup netbeans then you'll have to just use phpunit on the command line.
After the pear phpunit install just run phpunit on the command line and you should get some sort of 'help' output.
Edit : Step by step details.
I'm going to assume you have xdebug, php, netbeans installed from your comments. It seems like your only issue is installing phpunit.
Here goes.
Open up a command prompt
Open a browser window.
In your browser go to http://pear.php.net/go-pear
Save the text file that comes up into the directory php is installed in.
Go to the php directory php is installed in via the cd command on the terminal.
Type in the command php go-pear.phar
Follow the installation instructions for pear and pick the options that make the most sense. I just install everything in the php directory so php and pear live in the same place.
After pear is installed type in the following commands ( from the phpunit install website : http://www.phpunit.de/manual/current/en/installation.html ) You might have to use sudo here, if you're on windows maybe not.
pear config-set auto_discover 1
pear install pear.phpunit.de/PHPUnit
9 Run phpunit -h on the command line and you should get some help message. If you're on windows you might have to open up a new command line prompt before you try this.
Need to downgrade php to 5.2.x, so I followed this tutorial:
http://andreys.info/blog/2010-03-25/compile-php-5-2-on-osx-10-6-snow-leopard#comment-631
I'm on snow leopard 10.6.4, with xcode installed.
So I compiled php5.2.x and completed the tutorial. phpinfo() loaded within the browser at htp://localhost says 5.2.x, Great!! But, Terminal command "php --version" says 5.3.x ??
While compiling/installing php5.2.x, the new module file replaced the php5.3.x module here:
/usr/libexec/apache2/libphp5.so
So where is Terminal getting 5.3.x from?
Do I have two php versions being loaded?
Should I even care?
For a more direct solution to the problem:
Rename the OLD version of PHP
sudo mv /usr/bin/php /usr/bin/php5424
Create a Symbolic link for your new version of php so it can live in /usr/bin
sudo ln -s /usr/local/php5/bin/php /usr/bin/php
Check using which php. This should tell you which is being used.
Yes, looks like you have two installed at different locations.
Yes, mind what's being used where. Having multiple versions is absolutely valid (at least on a development or testing system) but you always should be aware of the versions being used.