Tip of the day: using Homebrew to get PHP Pear extensions behind a proxy

Submitted by Frederic Marand on

Four pears with leaves on a tableMost of the time, installing tools using Homebrew works flawlessly, including PHP these days. However, having to work in a client environment requiring a proxy, the PHP 8.1 post-install failed when updating Pear/Pecl channels, although the usual http_proxy and https_proxy were set and worked normally, including for the other Homebrew tasks. What could be going on ?

Turns out, the culprit is pear, which does not use those standard environment variables, but needs its own configuration, which is documented on https://pear.php.net/manual/en/guide.users.commandline.config.php

The key is to simply add that config from the Pear CLI:

pear config-set http_proxy http://(proxy IP):(proxy port)

After that, pear update-channels works..

.. and so do brew install php@8.1, or just brew postinstall php@8.1 if you got tired of waiting for a timeout in brew install php@8.1 and killed it with ^C.

That's all it takes!