When installing or upgrading PHP and crashing into this error that libz can not be found.
checking bundled sqlite3 library... yes
checking for ZLIB support... yes
checking if the location of ZLIB install directory is defined... no
READ THIS: https://git.io/brew-troubleshooting
If reporting this issue please do so at (not Homebrew/brew):
You can try to trigger Xcode to install the command line developer tools.
Usually you can run into errors like this when freshly installed Xcode or upgraded Xcode lately.
It is advised to start Xcode after installation or an upgrade to install the latest components.