Last active
July 3, 2022 14:33
-
-
Save andrerom/b360a1b2dbbebc6ec1861b8618d64e97 to your computer and use it in GitHub Desktop.
Shell command to be able to switch between MacOS liip PHP versions + set some default PHP config automatically
This 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 characters
#!/bin/sh | |
# This simple script lists the installed OSX PHP packages | |
# and lets you choose which one to activate (by changing the symlink). | |
# Fairly rudimentary, but it does the job (for me). | |
# | |
# Install to (*nix): /usr/local/bin/liip.sh | |
# Run using: sudo liip | |
# | |
# Tip: you can add an alias to your ~/.profile | |
# For example by typing the following lines in your terminal: | |
# > chmod u+x ~/liip.sh | |
# > echo "alias liip=\"~/liip.sh\"" >> ~/.profile | |
# > . ~/.profile | |
# | |
# You can find available PHP packages here: (http://php-osx.liip.ch/) | |
BASEDIR="/usr/local" | |
PHPVERSIONPREFIX="php5-" | |
SYMLINKNAME="php5" | |
printf "Please select a PHP directory:\n" | |
select PHPDIR in $BASEDIR/$PHPVERSIONPREFIX*/; do test -n "$PHPDIR" && break; echo ">>> Invalid Selection"; done | |
if [ -L $BASEDIR/$SYMLINKNAME ]; then | |
rm $BASEDIR/$SYMLINKNAME | |
fi | |
ln -s $PHPDIR $BASEDIR/$SYMLINKNAME | |
## !!! Custom PHP ini adjustments! | |
# Place your own edits to config here, doing it here to avoid having to re-do it everytime you install a new version | |
# Instead just run this script after installing new version and select it again so config is applied, same if you change this. | |
# 1: Disable imap plugin (by moving ini file to backup), it slows down php startup, noticable on cli | |
if [ -f $BASEDIR/$SYMLINKNAME/php.d/50-extension-imap.ini ]; then | |
mv $BASEDIR/$SYMLINKNAME/php.d/50-extension-imap.ini $BASEDIR/$SYMLINKNAME/php.d/50-extension-imap.ini.bak | |
fi | |
# 2: Your own cusotm settings which will overrride others set before, always overwrite the file in case of changes here | |
cat <<EOT > $BASEDIR/$SYMLINKNAME/php.d/999-my-dev.ini | |
; Optional: Disable some xdebug features that slows down PHP a lot, but keep it enabled for other features like debugging | |
xdebug.coverage_enable=off | |
; Optional: Enable opcache also for CLI | |
opcache.enable=1 | |
; Increase PHP memory limit, Composer needs it.. (PS: Someone up for improving Composer on memory usage?? => github.com/composer/composer) | |
memory_limit = 1536M | |
EOT | |
php -v |
@lcube45 that is a great point, I'm all for updating this, do you also have other customizations to this you'd recommend should be added?
@andrerom thanks for your feedback, nothing more to say on this snippet which by the way was helpful :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Just a tip for who has been fighting to make xdebug breakpoint works with IDE.
The 999-my-dev.ini file provided within this snippet sets xdebug.extend_info to false which disable breakpoints and interaction with your IDE (phpstorm or vscode).
Just to get things back set xdebug.extend_info to true in this ini file.
Hope this helps
ps : my setup : osx - php 7.1/7.2