You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在搭载Apple M1芯片的本地MacBook上启用Xdebug?

Enable Xdebug on Apple M1 Mac (PHP 8.0.10 CLI)

Hey there! Let's get Xdebug up and running on your Apple M1 Mac with PHP 8.0.10 CLI. I've gone through this setup a few times, so here's a straightforward guide that should work smoothly:

  • Install Xdebug via PECL
    Fire up your terminal and run this command. Since you're on an M1 chip, we'll enforce the arm64 architecture to avoid any mismatch issues:

    arch -arm64 pecl install xdebug
    

    Once installation finishes, it’ll output the path to the xdebug.so file (usually something like /opt/homebrew/lib/php/pecl/20200930/xdebug.so). Jot this down — you’ll need it in the next step.

  • Locate your PHP configuration file
    First, let’s find which php.ini your CLI PHP is using. Run:

    php --ini
    

    Look for the line labeled Loaded Configuration File — that’s the file we need to edit.

  • Enable Xdebug in php.ini
    Open the config file in your preferred editor (I use nano for quick terminal edits, but VS Code works too):

    nano /path/to/your/php.ini
    

    Scroll to the bottom and paste these lines, replacing the zend_extension path with the one you noted earlier:

    [Xdebug]
    zend_extension="/opt/homebrew/lib/php/pecl/20200930/xdebug.so"
    xdebug.mode=debug
    xdebug.client_host=localhost
    xdebug.client_port=9003
    xdebug.start_with_request=yes
    

    A quick breakdown of these settings:

    • xdebug.mode=debug: Turns on core debugging functionality
    • start_with_request=yes: Triggers Xdebug automatically whenever you run a PHP script from the CLI
    • client_port=9003: This is Xdebug 3’s default port — most IDEs support this out of the box, but you can adjust it if needed.
  • Verify Xdebug is active
    Run this command to confirm everything’s working:

    php -v
    

    You should see a line in the output like this:

    with Xdebug v3.x.x, Copyright (c) 2002-202x, by Derick Rethans

    If that shows up, you’re all set!

  • Quick IDE setup tip
    If you’re using VS Code, PHPStorm, or another IDE, just make sure the debug port in your IDE’s settings matches 9003 (Xdebug 3 switched from the old 9000 port used in Xdebug 2). No extra hoops to jump through for basic CLI debugging after that.

内容的提问来源于stack exchange,提问作者itsmeguruharry

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 12:37:32