Using Valet with php version installed via MacPorts #1456
-
Hello, I have an old MacBook Pro running Catalina OS so Homebrew doesn't support my upgrade from php 8.0 to php 8.1. I managed to install php 8.1 using MacPorts instead of Homebrew:
Is there anyway I can use Valet with this php version? When I try to use it Valet says it's not installed and it tries to install it again via Homebrew:
Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
Strictly speaking, no: there's no awareness of MacPort's PHP binaries in Valet. But, I'm exploring it ... for the same reasons you mention. The problem is not so much having a command-line PHP binary via MacPorts ... because you can install it and just add it to your PATH. That takes only a minute to do. |
Beta Was this translation helpful? Give feedback.
-
Bandaging PHP versions for older Mac's: using MacPortsTO BE CLEAR: THIS IS OFFICIALLY UNSUPPORTED AT THIS TIME. YOUR MILEAGE MAY VARY.
sudo port install php82 php82-calendar php82-curl php82-dba php82-exif php82-ffi php82-fpm php82-ftp \
php82-gd php82-gettext php82-gmp php82-iconv php82-intl php82-mbstring php82-mysql php82-opcache \
php82-openssl php82-pcntl php82-posix php82-pspell php82-soap php82-sockets php82-sodium php82-sqlite \
php82-tidy php82-xsl php82-zip (You may have reply Yes to several prompts.) (You can add/remove related extensions depending on your needs.)
sudo cp -n /opt/local/etc/php82/php.ini-development /opt/local/etc/php82/php.ini
sudo mkdir -p /opt/local/etc/php82/conf.d
echo ';' | sudo tee -a /opt/local/etc/php82/php.ini
echo 'include=/opt/local/etc/php82/conf.d/*.conf' | sudo tee -a /opt/local/etc/php82/php.ini
echo ';' | sudo tee -a /opt/local/etc/php82/php.ini
sudo cp -n ~/.composer/vendor/laravel/valet/cli/stubs/php-memory-limits.ini /opt/local/etc/php82/conf.d/php-memory-limits.ini
sudo cp -n /opt/local/etc/php82/php-fpm.conf.default /opt/local/etc/php82/php-fpm.conf
sudo cp -n ~/.composer/vendor/laravel/valet/cli/stubs/etc-phpfpm-valet.conf /opt/local/etc/php82/php-fpm.d/valet-fpm.conf
sudo sed -i '' "s#VALET_USER#"$USER"#" /opt/local/etc/php82/php-fpm.d/valet-fpm.conf
sudo sed -i '' "s#VALET_HOME_PATH#"/Users/$USER"/.config/valet#" /opt/local/etc/php82/php-fpm.d/valet-fpm.conf
sudo sed -i '' "s#valet.sock#valet82.sock#" /opt/local/etc/php82/php-fpm.d/valet-fpm.conf
(You should see a new empty file named
There's a small possibility that you might need to run NOTES:
If Nginx gives a 502 error, check its logs at PHP CLI (Command-Line)Remember: when you call artisan commands and especially when you call composer commands, you want them to use the version of PHP your project is expecting, else you'll build outdated composer.lock files (well, that may not matter if you're not publishing your lock file to git or as part of your CI or deployment processes). One-time
|
Beta Was this translation helpful? Give feedback.
-
I suggest using Mac ports by default to manage valet dependencies. It's way faster than Homebrew and Supports way more Devices. |
Beta Was this translation helpful? Give feedback.
Bandaging PHP versions for older Mac's: using MacPorts
TO BE CLEAR: THIS IS OFFICIALLY UNSUPPORTED AT THIS TIME. YOUR MILEAGE MAY VARY.
Install MacPorts via their website.
Add the MacPorts binaries path to your PATH via your
~/.zshrc
or equivalent file so they can be used via the command-line:export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
Install PHP and PHP-FPM for a specific version, using this command (all on one line):