Installing ext-http for php 8.3 in Laravel Herd
Pecl ext-http
I don’t know why but googling this lead me all over the place, from stack overflow from 2014 to a sassy laracasts post telling someone to google how to fix it.
Well, it turns out it’s not very straight forward to remedy the problem. As far as I’m concerned, having to compile anything for end users is annoying and I would welcome pre-shipped binaries into herd (hell, i’ll even help build them). But alas, here we are.
Using pecl install pecl_http
simply did not work.
These instructions are for Mac m2.
Fixing Larvel Herd ext-http on mac
Php with homebrew and for some reason could not get ext-http to install properly.
If you’re missing zlib like my colleague was, brew install it with:
brew install zlib
Php 8.3 includes raphf by default it seems. However, it will not include headers. This is viewable by checking pecl list-files raphf
. It showed folders, but those folders were empty.
Reinstalling raph fixed the issue:
pecl uninstall raphf
pecl install raphf
Next, export some additional flags for openssl (brew install openssl
) so it’s available for compilation. This is needed for ext-http.
echo 'export PATH="$(brew --prefix openssl@3)/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
export LDFLAGS="-L$(brew --prefix openssl@3)/lib"
export CPPFLAGS="-I$(brew --prefix openssl@3)/include"
Next, if you run pecl install pecl_http
it will manually ask for like 900 folders. Here are the default paths for mac that worked for me and automatically shoves them into the install script:
You can swap paths if needed of course:
printf "/opt/homebrew/opt/zlib\n\
/opt/homebrew/opt/curl\n\
/opt/homebrew/opt/libevent\n\
/opt/homebrew/opt/icu4c\n\
/opt/homebrew/opt/libidn2\n\
/opt/homebrew/opt/libidn\n\
/opt/homebrew/opt/libidn2\n\
/opt/homebrew/opt/libidn\n" | pecl install pecl_http
Or, if you want to copy paste paths manually for each of those, you can just run this:
pecl install pecl_http
Finally, open your herd ini file (herd -> open configuration files path -> 83) and add the following. You may need to replace 8.3.13_1
with the right PHP version for you. Scroll up and look where the extension was compiled.
extension=/opt/homebrew/Cellar/php/8.3.13_1/pecl/20230831/raphf.so
extension=/opt/homebrew/Cellar/php/8.3.13_1/pecl/20230831/http.so
Composer should now work without issue! Yay!