Search code examples
phpmacosxampphomebrewxdebug

How to install Xdebug for XAMPP PHP, not macOS PHP?


I installed Xdebug using homebrew for my system's PHP and it went fine.

enter image description here

But I'm trying to debug in my IDE, PhpStorm, which is using XAMPP as the server. It's a different PHP installation (I'm pretty sure!?)

enter image description here

I say this because obviously, it's missing the "xdebug.." and "Zend OPache.." stuff in the version command. I'm running that version command from PhpStorm's run command tool, BTW.

Lastly, I super know it's not installed due to this blinding reminder that I'm absolutely, beyond any possible shadow of a doubt, lost in the sauce.

enter image description here

I think it's about time I learn how to use the ol' terminal.

Any tips on how to use homebrew to install Xdebug on XAMPP's PHP?


Solution

  • Solved.

    I modified XAMPP's php.ini file to point to the xdebug.so that homebrew installed, zend_extension="/opt/homebrew/Cellar/php/8.2.3/pecl/20220829/xdebug.so"

    Then, I restarted the XAMPP server and ran this in terminal /Applications/XAMPP/xamppfiles/bin/php -v

    Before the expected PHP info, there were some errors. Several times in the warnings it stated "...(mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')..." Oops.. I swore I chose x86_64..

    So, I ran the following in terminal: pecl uninstall xdebug

    Then, arch -x86_64 sudo pecl install xdebug

    Following that I again ran /Applications/XAMPP/xamppfiles/bin/php -v and, voila!

    PHP 8.2.0 (cli) (built: Dec 29 2022 08:42:31) (NTS)
    Copyright (c) The PHP Group
    Zend Engine v4.2.0, Copyright (c) Zend Technologies
        with Xdebug v3.2.0, Copyright (c) 2002-2022, by Derick Rethans
    

    Xdebug installed :] Works in my IDE too.