![]() Configuring the Command-line to use MAMP's php.ini ![]() You can check if everything was applied as expected by executing php -ini and seeing the paths are pointing to MAMP. ![]() Remember that everytime you change your Profile you need to "reload" it by doing source ~/.bash_profile (or whatever file you are using). Mines it's ~/.zshrc because I use Oh My Zsh. If you are using the default Terminal coming with macOS chances are the Profile will either be ~/.bash_profile or ~/.bashrc. Your Command-line's Profile file depends on your shell. #export PATH=/Applications/MAMP/bin/php/php7.4.9/bin:$PATHĪs you can see I'm adding a different line per PHP version I want to potentially have available on the Command-line (PHP 7.1.33, PHP 7.2.33, etcetera) but having them all but one (PHP 7.3.21) commented with the # at the beginning.Įvery time you switch the PHP version in MAMP you should come back to the Profile and leave uncomment the same version so the Terminal and MAMP match. #export PATH=/Applications/MAMP/bin/php/php7.2.33/bin:$PATHĮxport PATH=/Applications/MAMP/bin/php/php7.3.21/bin:$PATH You need to edit your Terminal's Profile in order to add the following to the end: #export PATH=/Applications/MAMP/bin/php/php7.1.33/bin:$PATH Configuring the Command-line to use MAMP's PHP This next one is how I personally do it because it's easy to implement and it also covers something most of other guides won't which is configure the Terminal to also use the same php.ini MAMP uses. Out there you can find enough guides that helps you archive this because, frankly, there are plenty of methods to get this done. ![]() The idea behind changing the Command-line to start using the PHP coming with MAMP and its configuration is to be able to switch rapidly between PHP versions and to have the configuration for PHP in only one place. You can leave a comment on my original post.By default, after installation, MAMP will make its PHP binaries "available on the browser" while the Terminal will keep on using the system's PHP with its own configuration. I understand this hack is no longer necessary in MAMP 3 which offers better PHP version management. You’ll be pleased to see that you can now choose the PHP version you actually want to use: Now restart MAMP and see your handy work in action. I’m renaming my oldest version and my newest version so that I’m left with PHP 5.3.27 and PHP 5.4.19: This is the folder that houses all your PHP versions. Open a Finder window and navigate to the following folder: To make use of this feature, shut down MAMP, then find the correct folder and simply rename the versions you don’t need to something else – for example, add an x to the front. Only two versions are displayed at a time, namely the oldest and the newest you have in a certain directory. The good news is that MAMP ships with several other PHP versions, and you can even download more from (in the downloads section). I need it to reflect my production environment. That’s all good if I actually needed either version – but sadly 5.2.x is too old for me, and 5.5.x doesn’t quite work and is a bit too cutting edge. When I switch to the other version MAMP restarts and I can refresh my browser to see my project running on the other PHP version. Here I’m using MAMP 2.2 (even though 3.x has been released already) and I have PHP 5.2.17 and PHP 5.5.3. If you’re using MAMP that’s fairly easy to do: head over to the MAMP Start Screen, select Preferences and see two versions to choose from. Sometimes you need to test your projects against multiple versions of PHP.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |