The issue is related with the openssl package.
I found the solution here:
https://stackoverflow.com/questions/68957915/macos-10-12-brew-install-openssl-issue
Edit the openssl with the following `brew edit openssl`
and add the line:
```
-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
```
To args array in `configure_args`, as below:
```
def configure_args
args = %W[
--prefix=#{prefix}
--openssldir=#{openssldir}
no-ssl3
no-ssl3-method
no-zlib
##### add the line here ####
-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
]
on_linux do
args += (ENV.cflags || "").split
args += (ENV.cppflags || "").split
args += (ENV.ldflags || "").split
args << "enable-md2"
end
args
end
```
Then you try again to install the PHP. I installed php@7.4.
```
brew install php@7.4
```
I managed to resolve it by editing formula (`brew edit openssl`)
and adding
```
-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
```
to args array in `configure_args`.
As below:
```
def configure_args
args = %W[
--prefix=#{prefix}
--openssldir=#{openssldir}
no-ssl3
no-ssl3-method
no-zlib
##### add the line here ####
-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
]
on_linux do
args += (ENV.cflags || "").split
args += (ENV.cppflags || "").split
args += (ENV.ldflags || "").split
args << "enable-md2"
end
args
end
```