Using Xdebug

introduction

Debug is a programming ability, the sooner you learn the better. And Xdebug is the most powerful tool for debugging PHP, this article is to introduce how to use Xdebug .

Install

 1 
 pecl install xdebug

Modify the default configuration of xdebug (optional):

View the configuration file of php.ini :

 1 
 php --ini

View debug configuration

 1 
 php -i | grep xdebu

After getting the configuration file of php.ini , add the following code:

 1 2 3 4 
 [xdebug] xdebug.max_nesting_level=512 xdebug.mode=debug xdebug.client_host=127.0.0.1

Configure Phpstorm

PhpStorm > Preferences configuration, find PHP > Servers , add a Server, the configuration is as follows:

  • Name: serverName
  • Host: 127.0.0.1
  • Port: 8000
  • Debugger: Xdebug

Switch xdebug place in the menu at the top of Phpstorm as shown above

After enabling xdebug, just mark the place where you need to break the point.

trigger

The default is to not trigger the breakpoint function

browser

Installing the Chrome Xdebug Helper extension will automatically add parameters to each request.

Postman

Add parameter XDEBUG_SESSION_START=PHPSTORM to URL

This article is reprinted from: https://blog.forecho.com/use-xdebug.html
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment