These are my instructions for compiling a new version of PHP via Phpbrew on Mac High Sierra, with the latest versions of cURL and OpenSSL that Composer seems to need.
/usr/local/bin must come before /usr/bin in the PATH when using Homebrew.
export PATH=/usr/local/bin:$PATH