mac下xampp+vscode进行php程序调试

  公司的官网,是 php 做的,搭建调试环境做个记录,我用的是 mac 机。

  1、下载最新的xampp,我的版本是XAMPP for OS X 5.6.31;

  2、找到 php.ini,/Applications/XAMPP/xamppfiles/etc/php.ini,注释掉这一句zend_extension=opcache.so,并在下面添加         

   zend_extension = /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so

   [XDebug]
   xdebug.remote_enable = 1
   xdebug.remote_autostart = 1

  3、下载 vscode 的 IDE,并安装插件PHP Debug;

  4、在 vscode 的debug 下启动监听,并打上断点;

  5、在浏览器打开地址,断点生效。

 

关于php7.4.27

a、利用phpinfo()或者在命令行下cd到php.exe路径运行php -i )

b、复制php信息到以下地址   https://xdebug.org/wizard

c、按步骤进行

复制代码
Installation Wizard
Summary
Xdebug installed: no
Server API: Apache 2.0 Handler
Windows: no
Zend Server: no
PHP Version: 7.4.27
Zend API nr: 320190902
PHP API nr: 20190902
Debug Build: no
Thread Safe Build: no
OPcache Loaded: yes
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-20190902
Instructions
Download xdebug-3.1.2.tgz
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.
Unpack the downloaded file with tar -xvzf xdebug-3.1.2.tgz
Run: cd xdebug-3.1.2
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:      20190902
Zend Extension Api No:   320190902
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-20190902
Update /Applications/XAMPP/xamppfiles/etc/php.ini and add the line:
zend_extension = xdebug
Make sure that zend_extension = xdebug is below the line for OPcache.
Restart the Apache Webserver
复制代码

vscode查看 PHP Debug 插件

复制代码
Configure PHP to use Xdebug by adding zend_extension=path/to/xdebug to your php.ini. The path of your php.ini is shown in your phpinfo() output under "Loaded Configuration File".

Enable remote debugging in your php.ini:

For Xdebug v3.x.x:

xdebug.mode = debug
xdebug.start_with_request = yes
For Xdebug v2.x.x:

xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_port = 9000
There are other ways to tell Xdebug to connect to a remote debugger, like cookies, query parameters or browser extensions. I recommend remote_autostart (Xdebug v2)/start_with_request (Xdebug v3) because it "just works". There are also a variety of other options, like the port, please see the Xdebug documentation on remote debugging for more information. Please note that the default Xdebug port changed between Xdebug v2 to v3 from 9000 to 9003.
复制代码

 

posted @   会飞的斧头  阅读(2136)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示