I've cobbled the following procedure together from a couple of different questions here, and on the Apple support forums. None of them have worked on their own, but this appears to be close. The problem is I wind up with an unsigned extension that MacOS refuses to load; can anyone help me get that last (I hope) problem resolved?

1. Install autoconf.

cd ~/Downloads
curl -O -L http://ftpmirror.gnu.org/autoconf/autoconf-2.69.tar.gz
tar -xzf autoconf-2.69.tar.gz
cd autoconf-2.69
sudo make install

2. Install automake

cd ~/Downloads
curl -O -L http://ftpmirror.gnu.org/automake/automake-1.15.tar.gz
tar -xzf automake-1.15.tar.gz
cd automake-1.15
sudo make install

3. Install libtool

cd ~/Downloads
curl -OL http://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz
tar -xzf libtool-2.4.6.tar.gz
cd libtool-2.4.6
sudo make install

4. Install CMake

Download the disk image from: https://github.com/Kitware/CMake/releases/download/v3.16.0-rc3/cmake-3.16.0-rc3-Darwin-x86_64.dmg

Mount the image and drag the application to your Applications folder.

Edit your .zshrc file (or create one in your home directory if you don't have one).

Add the line:

export PATH="$PATH:/Applications/CMake.app/Contents/bin"

Save the file and type the command:

source ~/.zshrc

5. Install libzip

cd ~/Downloads
curl -OL https://libzip.org/download/libzip-1.5.2.tar.gz
tar -xzf libzip-1.5.2.tar.gz
cd libzip-1.5.2
mkdir build
cd build
cmake ..
sudo make install

6. Create a temporary copy of phpize that uses Xcode's libraries

cd ~
cp /usr/bin/phpize ~/Desktop/

Edit the copy of phpize that's now on your desktop, and change this line:

includedir="`eval echo ${prefix}/include`/php"



Save the modified phpize file.

7. Download the source code for the correct version of PHP -- 7.3.9 as of MacOS 10.15.1

cd ~/Downloads
curl -O -L https://www.php.net/distributions/php-7.3.9.tar.bz2
tar -yxf php-7.3.9.tar.bz2
cd php-7.3.9/ext/zip

8. Build the extension

CFLAGS="-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/php/main -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/php/Zend -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/php/TSRM -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/php" ./configure --with-zlib-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr --with-php-config=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/bin/php-config
make install
sudo mkdir /usr/local/lib/php/extensions
sudo mv modules/zip.so /usr/local/lib/php/extensions/

NOTE: I expect make install to fail due to permission errors, but one of the other discussions I found suggested that this step was necessary to sign the code. It doesn't seem to have that effect, however.

9. Edit the /etc/php.ini file


10. Test with command:

php --version


PHP Warning: PHP Startup: Unable to load dynamic library 'zip' (tried: /usr/local/lib/php/extensions/zip (dlopen(/usr/local/lib/php/extensions/zip, 0x0009): dlopen(): file not found: /usr/local/lib/php/extensions/zip), /usr/local/lib/php/extensions/zip.so (dlopen(/usr/local/lib/php/extensions/zip.so, 0x0009): code signature in (/usr/local/lib/php/extensions/zip.so) not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.)) in Unknown on line 0


Good summary. I did not need 2 and 3.

Then for the signature

11. You need to start XCode and add an account.

Add an account to XCode

Download a certificate

12. In terminal check with certtool y for your new Signing Key. It's named like:

Common Name     : Apple Development:
xxxxx.xxxxx@appleid.xxxxxx.de (xxxxxxxx)

Still with your user in the terminal sign the file (move it back if not anymore in the build folder, otherwise you end with a permission error)

codesign -f -s "Apple Development: xxxxx.xxxxx@appleid.xxxxx.de" /usr/local/lib/php/extensions/zip.so

Move it to the target folder, run php --version and you end with:

PHP Warning: PHP Startup: Unable to load dynamic library 'zip' (tried: /usr/local/lib/php/extensions/zip (dlopen(/usr/local/lib/php/extensions/zip, 0x0009): dlopen(): file not found: /usr/local/lib/php/extensions/zip), /usr/local/lib/php/extensions/zip.so (dlopen(/usr/local/lib/php/extensions/zip.so, 0x0009): code signature in (/usr/local/lib/php/extensions/zip.so) not valid for use in process: mapping process is a platform binary, but mapped file is not)) in Unknown on line 0 PHP 7.3.11 (cli) (built: Feb 29 2020 02:50:36) ( NTS )

Ok, i looked around the internet (insightful resurce), and the bits i found paint a dark image. In short: It's not possible anymore with Mac Os Catalina.

The errormessage tells it too. The Php environment is signed as system component (platform binary) and is installed by default. Mac Os Catalina enforces that platform binaries only load code which is also a platform binary. Which one can not do, because you are not Apple.

Leaving two possible options. Disabling the whole Signature enforcement stystemwide whic is a bad idea. Or setup a replacement Php completely selfbuild or with homebrew.

  • This answer seems to be incomplete – Ramhound Mar 27 '20 at 19:02
  • 1
    With the March 30, 2020 edit, this is a great answer, though it may not be what you were hoping for. I particularly like the explanation concerning certificates (which is a murky topic and most of the time is explained poorly by others, who may be making assumptions of their reader's knowledge). This issue does not prevent php, based on my experience using the default 7.3.11 on Catalina 10.15.3, from executing the PHP scripts from either the CLI or those associated with a website.under brew's Apache. It just produces a PHP Warning; albeit one that would be nice to get rid of. – gone Jul 18 '20 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.