Unable to use PHPIZE after update to MacOS Mojave
Asked Answered
S

4

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:
Supersensible answered 1/10, 2018 at 13:45 Comment(5)
do you have /usr/include/php/main/ and /usr/include/php/main/php.h?Skimpy
No, none of these exists on my system. Actually there is no /usr/include folder. Maybe in Mojave is another folder ?Supersensible
it seems that your os move or remove some file.you can re-install phpSkimpy
I'm using the default PHP installation of Mac Os Mojave. It probably changed folder locationsSupersensible
I found this resource invaluable: bbqsoftwares.com/blog/xdebug-catalinaRegardless
D
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 /
Defroster answered 2/10, 2018 at 15:57 Comment(9)
Not potential. Absolutely the better solution.Expand
Thanks. This works and fixes everything for the OS installed PHP. I came across this issue while trying to setup xdebug.Crusty
had need to run xcode-select --install first. after a re-install of my OS xcode was gone. i guess.Marlanamarlane
It appears the new version of Xcode may have removed this pkg. I have not found a solution yet.Defroster
Before I could run the above command I also had to re-install Xcode developer tools from here: developer.apple.com/download/more and specifically had to select "Command Line Tools (macOS 10.14) for Xcode 10.2"Hitoshi
How to apply this solution for MacOs Catalina ?Supersensible
@Supersensible have you found a solution for MacOS Catalina?Eyrie
@AbanaClara Not yet, i opened a new quesiton : #58693502Supersensible
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.)"Willodeanwilloughby
E
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.

Earl answered 13/4, 2019 at 22:12 Comment(0)
S
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

Skimpy answered 1/10, 2018 at 14:52 Comment(6)
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 ?Supersensible
Actually this file : "/usr/include/php/main/php.h" is on "/usr/local/php5-7.1.10-20171002-090111/include/php/main"Supersensible
do you have more than one phpize script?Skimpy
No. I could solve the problem after doing what you suggested., thanks !Supersensible
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'"Supersensible
phpize is a readonly file. even cannot be edited by sudoPertain
A
-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 /
Albright answered 28/11, 2018 at 13:35 Comment(1)
duplicate answer.Defroster

© 2022 - 2024 — McMap. All rights reserved.