Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xdebug failed install on Mac m1

Tags:

php

xdebug

I'm trying to install Xdebug on my Mac m1, I followed this page(https://xdebug.org/docs/install) to install. This is the step I followed:

step1 => go to cmd: arch -x86_64 sudo pecl install xdebug

step2 => go to php.ini delete this line of code

zend_extension="xdebug.so"

step3 => go to php.ini add this

[xdebug]
zend_extension=/opt/homebrew/lib/php/pecl/20190902/xdebug.so
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port="9003"

step4 => go to cmd: php -v

The error shows:

enter image description here

How can I solve this problem? Thanks

like image 358
leojail Avatar asked Jun 18 '21 06:06

leojail


2 Answers

What happened here is that you built a x86_64 build of the extension, but homebrew likely used the arm64e architecture. These architectures are not compatible.

You can verify what your PHP's architecture is with:

file `which php`

If that says arm64e, then you need the original command from the documentation:

sudo pecl install xdebug

And if it's x86_64, then you need the command modified for Apple's dual architecture:

arch -x86_64 sudo pecl install xdebug

For what it's worth, the docs say: On Apple M1 hardware, you might instead need to use..., not must.

like image 112
Derick Avatar answered Oct 09 '22 17:10

Derick


If you encounter this:

  • file which php result shows Mach-O 64-bit executable arm64.
  • sudo pecl install xdebug still resulted in the wrong architecture problem.

Try this:

arch -arm64e sudo pecl install xdebug

Note: arch -arm64 shown bad cpu type error in my case.

like image 21
Marinne Avatar answered Oct 09 '22 16:10

Marinne