skip to Main Content

Honestly, I’ve tried everything trying to get this working. I am a bit new to MacOS but I am starting to get the hang of it.

I’ve installed Xdebug on my mac with XAMPP and VSCode as editor. It’s still just not working and I think it is not connecting.

php.ini

[XDebug]
zend_extension = /Applications/XAMPP/xamppfiles/lib/php/extensions/xdebug.so
xdebug.remote_port = 9003
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = "/Applications/XAMPP/xamppfiles/temp"
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "localhost"
xdebug.remote_enable = On
xdebug.trace_output_dir = "/Applications/XAMPP/xamppfiles/temp"

VSCode launch.json:

      "type": "php",
      "request": "launch",
      "port": 9003

And yes, my file is at that exact location.
If anyone has any glues on what’s going on, I’ll be glad to know.

UPDATE
So I’ve check my error logs and I’ve gotten this problem:

[12-Oct-2021 07:00:06 UTC] PHP Warning: Failed loading Zend extension ‘xdebug’ (tried: /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20190902/xdebug (dlopen(/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20190902/xdebug, 9): image not found), /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so (dlopen(/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so, 9): no suitable image found. Did find:
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so: mach-o, but wrong architecture
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so: mach-o, but wrong architecture)) in Unknown on line 0

On the website it says that xdebug is only supported with homebrew. But installing php with homebrew is not the same thing as with XAMPP. I am starting to think that I just cannot use XAMPP and XDebug together but have to use the integrated apache.

XDebug Wizard:

Install the pre-requisites for compiling PHP extensions.
On your Mac, we only support installations with ‘homebrew’, and brew install php && brew install autoconf should pull in the right packages."

When I look up the php version in the terminal it gets the version in homebrew, so I deleted it. It may be that when I used ./configure it took the PATH to homebrew. That is probably why the image is not correct.

Whatever the problem may be, I cannot find any kind of solution and have tried many things

2

Answers


  1. Chosen as BEST ANSWER

    After days trying to fix this I finally got it. What you need to do is the following:

    Step 1: Check PATH in Terminal

    which php
    

    Step 2: If this is not your current http server like XAMPP or MAMP please correct it by making a ./bash_profile MAMP Example: https://gist.github.com/irazasyed/5987693 XAMPP Example: https://gist.github.com/djandyr/c04950a1375e96814316

    Step 3: Check php version again (repeat step 1). If this is the version of your http server then it's OK.

    Step 4: Type in terminal

    php -v
    

    Step 5: If your xDebug cannot be loaded it will tell you why now. (or in the error logs). As I've said I've got a M1 Macbook and I think xDebug doesn't support M1.

    Step 6: To install xDebug terminal:

    arch -x86_64 sudo pecl install xdebug
    

    Step 7: Now restart all and try your phpinfo.

    Happy debugging!


  2. The clue is in this message:

    mach-o, but wrong architecture

    On M1, your PHP can either be compiled for the x86_64 or arm64 architectures. The pecl tool can’t guess which one it is, so if your PHP is compiled with say x86_64 and the default compiler setting is arm64, then you’ll get the above warning.

    This means, that sometimes you have to run PECL with:

    arch -x86_64 sudo pecl install xdebug
    

    The arch -x86_64 part will set up the environment to compile Xdebug as x86_64 binary.

    You can check what the architecture for your PHP is, by using:

    file /full/path/to/php
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search