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 @ 2017-11-22 16:13  会飞的斧头  阅读(2130)  评论(0编辑  收藏  举报