Last active
          November 18, 2022 17:15 
        
      - 
      
- 
        Save davidwebca/0011b6da0ce6f75a4d91547fa9a94ae4 to your computer and use it in GitHub Desktop. 
Revisions
- 
        davidwebca revised this gist Nov 18, 2022 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,4 +11,9 @@ export PATH=/Applications/MAMP/Library/bin:$PATH ``` ### Note This is different from other scripts floating around which usually tries to select the latest PHP version. In my case, I needed to be able to swap around versions and not always use the latest PHP version so I had to find this solution. But if you need to need the latest PHP version at all time on cli, here's how you would change the first line: ```bash PHP_VERSION=`ls /Applications/MAMP/bin/php/ | sort -n | tail -1` ``` This is only working when Apache is selected in MAMP. I don't know if Nginx is setup only as a reverse proxy in MAMP, but if so it could still work for you in that case, otherwise we would have to edit the grep to find the PHP version somewhere else. 
- 
        davidwebca revised this gist Nov 18, 2022 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,6 @@ In this file, you might see nothing or only a few configurations already. You ca PHP_VERSION=$(grep "^[^#\;]" "/Applications/MAMP/conf/apache/httpd.conf" | grep "LoadModule php" | awk -F'[\/]' '{print $6}') export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH export PATH=/Applications/MAMP/Library/bin:$PATH ``` ### Note 
- 
        davidwebca created this gist Nov 18, 2022 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ # How to set your command line to MAMP's version Since Mac OS comes with PHP bundled, even if you have MAMP, you'll find out that you can't use MAMP's versions on the command line. This is only true if you use the free version of MAMP since MAMP pro seems to have a feature to add that to the cli automatically. ## Open your ~/.bash_profile file or ~/.zshrc if using ZSH In this file, you might see nothing or only a few configurations already. You can safely ignore them and add this lower: ```bash PHP_VERSION=$(grep "^[^#\;]" "/Applications/MAMP/conf/apache/httpd.conf" | grep "LoadModule php" | awk -F'[\/]' '{print $6}') export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH export PATH=/Applications/MAMP/Library/bin:$PATH export PATH=~/Projets/Bash/wp-db/:$PATH ``` ### Note This is only working when Apache is selected in MAMP. I don't know if Nginx is setup only as a reverse proxy in MAMP, but if so it could still work for you in that case, otherwise we would have to edit the grep to find the PHP version somewhere else.