PECL extensions installation fails after update MacOS to Mojave (10.14)
Asked Answered
S

2

6

I use my Mac to develop three projects: a Android app, a iPhone app, and a Symfony project.

My Symfony project uses Redis and APCu extensions. This was installed (6 months ago) via PECL using:

sudo pecl install redis

and

sudo pecl install apcu

Yesterday, after update my mac to Mojave, and try to start my PHP's built-in Web Server as usual, I get the following error:

Attempted to load class "Redis" from the global namespace. Did you forget a "use" statement?

I also noticed that php.ini was removed during the installation, so I used the php.ini-previous to generate the php.ini again.

Also re-installed the Command Line Tools (was removed during installation):

xcode-select --install

And finally, I tried to install the redis extenison via PECL, again:

sudo pecl install redis

This time PECL throws an error:

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /private/tmp/pear/temp/pear-build-root1vQ0zO/redis-4.1.1/libtool --mode=compile cc  -I. -I/private/tmp/pear/temp/redis -DPHP_ATOM_INC -I/private/tmp/pear/temp/pear-build-root1vQ0zO/redis-4.1.1/include -I/private/tmp/pear/temp/pear-build-root1vQ0zO/redis-4.1.1/main -I/private/tmp/pear/temp/redis -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /private/tmp/pear/temp/redis/redis.c -o redis.lo
mkdir .libs
cc -I. -I/private/tmp/pear/temp/redis -DPHP_ATOM_INC -I/private/tmp/pear/temp/pear-build-root1vQ0zO/redis-4.1.1/include -I/private/tmp/pear/temp/pear-build-root1vQ0zO/redis-4.1.1/main -I/private/tmp/pear/temp/redis -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /private/tmp/pear/temp/redis/redis.c  -fno-common -DPIC -o .libs/redis.o
In file included from /private/tmp/pear/temp/redis/redis.c:27:
/private/tmp/pear/temp/redis/common.h:1:10: fatal error: 'php.h' file not found
#include "php.h"
         ^~~~~~~
1 error generated.
make: *** [redis.lo] Error 1
ERROR: `make' failed

How can solve this issue?

Sherri answered 26/9, 2018 at 8:0 Comment(4)
I'm having the same error when trying to use PHPIZE. It seems something related to PHP changed in Mojave , but i could not find out yet.Labile
I finally ended up reinstalling completely the system. After that, Mojave's PHP works the same as High Sierra's. I don't close the question hoping someone have a better solution. Just in case: support.apple.com/en-ca/HT204904 (Do not forget to erase the disk!)Sherri
I will search for another solution, reinstall the system from blank would be a big hassle...Labile
I reinstalled my whole system (Mojave) and still can't install intl with peclGaskill
I
5

Running the following command will reinstall the developer tools header files and fix the issue.

$ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
Ideography answered 2/10, 2018 at 15:25 Comment(3)
Thanks for your answer. Since I can't check if works, I'll wait to other users feedback, and then, accept it. Is it good for you?Sherri
I tried this solution and I still get an error while trying to : sudo pecl install intl. I'm getting error : #include <ext/standard/php_smart_str.h> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.Gaskill
Not working for Mojave 10.14.6 (18G6020), still get "fatal error: 'php.h' file not found"Evenings
A
1

You'll want to do

$ locate php.h

results should be something like:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php/main/php.h /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/php/main/php.h

Next, you'll want to disable SIP so you can create a folder in /usr/include and symlink the php dev dependencies to this folder, You have to boot into recovery to do this; restart you machine then hold cmd + R while it restarts, select terminal from the utilities menu.

run # csrutil disable && shutdown -r now

this will disable SIP and restart your machine.

Once your booted in, you'll want to create that folder we talked about like so sudo mkdir /usr/include

next we create a symlink to where the php dev files are located

$ ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/php /usr/include

You'll still have to enable SIP back, so boot back into recovery mode this time around you'll run

# csrutil enable && shutdown -r now, and thats it.

Albuminoid answered 24/10, 2018 at 13:7 Comment(1)
This Worked for me on catalina!Catty

© 2022 - 2024 — McMap. All rights reserved.