I've been struggling to get Xdebugger set up in PHPStorm on my Mac. Here's a summary of what I've tried and found. Any help would be much appreciated.
After much struggling and worrying that I messed up something, I wiped my Macbook and did a fresh install of MacOSX Mojave. I installed XAMPP for Mac v7.3.0 (PHP7.3.0). After installing XAMPP, I can open Chrome and go to localhost and I see the proper Apache sites such as dashboard, phpmyadmin, and phpinfo. I can confirm the php info shows v7.3.
There was a post here on SO where someone had 2 versions of php installed, so I found that I do indeed (with a fresh os install) have 2 versions of php. If I do a php --version from a command line, I get v7.1. But if I change to the XAMPP directory (/Applications/XAMPP/xamppfiles/bin), then php --info shows my version of 7.3. That tells me that I need to be careful when I reference commands in the future as I try to install Xdebug.
I also installed PHPStorm and set up PHP 7.3 in the languages, pointing to the ini file in the XAMPP directory. Everything works fine in PHPStorm in that I can create a test php file and call the phpinfo() method to display the correct php version of 7.3. But in the php language section of PHPStorm, the debugger shows that it is not installed.
So I think I have PHPStorm set up correctly with XAMPP and PHP 7.3.
In sorting out the different php versions, I think that the php 7.1 is in the path environment, which means that I need to refer to the absolute location if I want to use php 7.3 from the XAMPP folder. I ran php --version and php --ini which gave this output:
Terrys-MBP:~ terry$ /Applications/XAMPP/xamppfiles/bin/php --version
PHP 7.3.0 (cli) (built: Dec 11 2018 01:01:47) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
Terrys-MBP:~ terry$
Terrys-MBP:~ terry$
Terrys-MBP:~ terry$ /Applications/XAMPP/xamppfiles/bin/php --ini
Configuration File (php.ini) Path: /Applications/XAMPP/xamppfiles/etc
Loaded Configuration File:
/Applications/XAMPP/xamppfiles/etc/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Terrys-MBP:~ terry$
So I copied the phpinfo output to https://xdebug.org/wizard.php to get my custom instructions for installing Xdebug. This was the output and instructions. (sorry for the formatting)
Tailored Installation Instructions
Summary
Xdebug installed: no
Server API: Apache 2.0 Handler
Windows: no
Zend Server: no
PHP Version: 7.3.0
Zend API nr: 320180731
PHP API nr: 20180731
Debug Build: no
Thread Safe Build: no
Configuration File Path: /Applications/XAMPP/xamppfiles/etc
Configuration File: /Applications/XAMPP/xamppfiles/etc/php.ini
Extensions directory:
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-
20180731
Instructions
Download xdebug-2.6.1.tgz
Unpack the downloaded file with tar -xvzf xdebug-2.6.1.tgz
Run: cd xdebug-2.6.1
Run: phpize (See the FAQ if you don't have phpize.
As part of its output it should show:
Configuring for:
...
Zend Module Api No: 20180731
Zend Extension Api No: 320180731
If it does not, you are using the wrong phpize. Please follow this FAQ
entry and skip the next step.
Run: ./configure
Run: make
Run: cp modules/xdebug.so
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-
20180731
Edit /Applications/XAMPP/xamppfiles/etc/php.ini and add the line
zend_extension = /Applications/XAMPP/xamppfiles/lib/php/extensions/no-
debug-non-zts-20180731/xdebug.so
Restart the webserver
So, I followed the Taylored Instructions.
I downloaded xdebug-2.6.1.tgz and unpacked it in the /Applications/XAMPP/xamppfiles/ folder, then changed to the xdebug-2.6.1 folder.
Running phpize did not give me the correct output, so I clicked on this given link https://xdebug.org/docs/faq#custom-phpize to find which phpize file to use. So the phpize line I ran was:
/Applications/XAMPP/xamppfiles/bin/phpize from the
/Applications/XAMPP/xamppfiles/xdebug-2.6.1 folder
phpize gave the correct output, so I proceeded with the ./configure line:
./configure --with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config
I believe the first run gave me an error with autoconf that I downloaded from Homebrew. The next run gave me a message about a configuration file ".in" and ".ac" which I looked up and renamed the ".in" file since it was being phased out in favor of the ".ac" file. At this point, the ./configure line ran without any apparent errors.
Finally, I ran "make" and got these types of errors and warnings: (sorry the formatting is off with regards to the line lengths)
warnings:
/Applications/XAMPP/xamppfiles/xdebug-2.6.1/xdebug.c:1831:107: warning:
format
specifies type 'long' but the argument has type 'zend_long'
(aka 'long long') [-Wformat]
...nesting level of '%ld' reached, aborting!",
XG(max_nesting_level));
~~~ ^~~~~~~~~~~~~~~~~~~~~
%lld
./php_xdebug.h:323:15: note: expanded from macro 'XG'
#define XG(v) (xdebug_globals.v)
^~~~~~~~~~~~~~~~~~
and
/Applications/XAMPP/xamppfiles/xdebug-
2.6.1/xdebug_code_coverage.c:624:17: warning:
implicit declaration of function 'RT_CONSTANT_EX' is invalid in
C99
[-Wimplicit-function-declaration]
array_value = RT_CONSTANT_EX(opa->literals,
opcode.op2);
^
errors: (more but I just included the first one)
/Applications/XAMPP/xamppfiles/xdebug-2.6.1/xdebug_compat.c:56:71:
error: too
few arguments to function call, expected 6, have 5
return zend_get_zval_ptr(op_type, node, zdata, &should_free,
BP_VAR_R);
~~~~~~~~~~~~~~~~~
So now I'm stuck at the "make" line and have no idea how to proceed from here.
I'm sorry this is so long, but I wanted to be detailed on what I've tried so far, and, hopefully, to help others who may try the same procedures.