26

What i should do when i run PHPIZE and get the error below ? I already installed xcode command line tools.

grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:        
Zend Module Api No:     
Zend Extension Api No:
5
  • 1
    do you have /usr/include/php/main/ and /usr/include/php/main/php.h? Commented Oct 1, 2018 at 14:02
  • No, none of these exists on my system. Actually there is no /usr/include folder. Maybe in Mojave is another folder ? Commented Oct 1, 2018 at 14:28
  • it seems that your os move or remove some file.you can re-install php Commented Oct 1, 2018 at 14:32
  • I'm using the default PHP installation of Mac Os Mojave. It probably changed folder locations Commented Oct 1, 2018 at 14:37
  • 1
    I found this resource invaluable: bbqsoftwares.com/blog/xdebug-catalina Commented Apr 15, 2020 at 18:43

4 Answers 4

72

Potential better solution - force reinstall the header files. Fixed a ton of problems for me system wide.

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

$ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
Sign up to request clarification or add additional context in comments.

9 Comments

Not potential. Absolutely the better solution.
Thanks. This works and fixes everything for the OS installed PHP. I came across this issue while trying to setup xdebug.
had need to run xcode-select --install first. after a re-install of my OS xcode was gone. i guess.
It appears the new version of Xcode may have removed this pkg. I have not found a solution yet.
This does not work for me. I get the following error: "The install failed (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.)"
|
4

For some reason, I found Xcode command line tools was not installed completely on my Mac, Finally I solved this problem as follow:

 1. xcode-select --install
 2. cd /Library/Developer/CommandLineTools/Packages/ 
 3. open macOS_SDK_headers_for_macOS_10.14.pkg

Note: After doing step2, if there is no .pkg file in the dir. maybe this solution will not help you.

Comments

2

find the phpize and edit it,

~$ whereis phpize
phpize: /usr/local/bin/phpize
~$ vim  /usr/local/bin/phpize

in my phpize script it is like that

prefix='/usr/local/php7'   ## where you should edit
datarootdir='/usr/local/php7/php'
exec_prefix="`eval echo ${prefix}`"
phpdir="`eval echo ${exec_prefix}/lib/php`/build"
includedir="`eval echo ${prefix}/include`/php"
...

phpize_get_api_numbers()
{
  # extracting API NOs:
  PHP_API_VERSION=`grep '#define PHP_API_VERSION' $includedir/main/php.h|$SED 's/#define PHP_API_VERSION//'`
  ZEND_MODULE_API_NO=`grep '#define ZEND_MODULE_API_NO' $includedir/Zend/zend_modules.h|$SED 's/#define ZEND_MODULE_API_NO//'`
  ZEND_EXTENSION_API_NO=`grep '#define ZEND_EXTENSION_API_NO' $includedir/Zend/zend_extensions.h|$SED 's/#define ZEND_EXTENSION_API_NO//'`
}

if you comfirm that you have the header file but the phpize script configure is wrong ,you can edit the row

prefix='/usr/local/php7'

and php.h is in

$ pwd
/usr/local/php7/include/php/main
$ ls  php.*
php.h

if not ,you can compile php by yourself

6 Comments

My php folder is /usr/local/php5-7.1.10-20171002-090111 . i edited prefix='/usr/local/php5-7.1.10-20171002-090111' and datarootdir='/usr/local/php5-7.1.10-20171002-090111/php', but i still get the same error when calling PHPIZE... any hints ?
Actually this file : "/usr/include/php/main/php.h" is on "/usr/local/php5-7.1.10-20171002-090111/include/php/main"
do you have more than one phpize script?
No. I could solve the problem after doing what you suggested., thanks !
Now i upgraded to Catalina, i'm having the same issue, but i can't edit phpize anymore even as sudo, i get this error : "Failed to save 'phpize': Command failed: "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" --file-write "/var/folders/dc/3d93lth116q91kx94ms37rd40000gn/T/code-elevated-dynago" "/usr/bin/phpize" Error using --file-write: EPERM: operation not permitted, open '/usr/bin/phpize'"
|
-2

I had the same issue as described above, only I was trying to install xdebug on macOS Mojave.

I resolved the issue by executing:

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

1 Comment

duplicate answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.