Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of remote Multi-session debugging in PHP

Shulou Source: shulou.com Published: 2022-06-03 19:36:26 11月12日 Update

This article mainly introduces the example analysis of remote multi-session debugging in PHP, which is very detailed and has certain reference value. Friends who are interested must finish it!

First, background introduction

What problem to solve: when multiple project breakpoints are debugged, the www.mysite.com project will call the api.mysite.com project REST API, and when the action is triggered under the www.mysite.com project, it is more convenient to debug the interface in the api.mysite.com project directly.

Suitable for what scenarios: cross-project debugging, remote debugging, more convenient and easy to use than simple var_dump.

Second, remote debugging configuration

Nginx+PHP-fpm environment, configuring php.ini extension

[Xdebug] zend_extension = / usr/local/php56/lib/php/extensions/no-debug-non-zts-20131226/xdebug.soxdebug.remote_enable=1remote_handler=dbgpxdebug.remote_host=localhostxdebug.remote_port=9000xdebug.idekey=XDEBUG

Note: whether the php of CLI environment and the php of fpm use different php.ini configuration files, you need to configure the php.ini corresponding to fpm.

Check whether the configuration is correct

Map remote (host 10.99.1.185) port 9000 to local port 9000:

Ssh-CNg-R 9000:localhost:9000 root@10.99.1.185

After installing openssh locally, you can use the ssh command directly.

You can see that port 9000 is occupied by ssh on the server.

PHPSTORM also needs to configure Xdebug to enable multiple debugging sessions at the same time, port 9000, to accept external requests.

Configure path mapping, domain name, port related to the project

Third, debug configuration across sessions (projects)

The core of cross-project debugging is to send the conditions that trigger Xdebug debugging as parameters to the api.mysite.com project or other subsequent projects.

The www project code is as follows:

Frontend.php

Tags: Project configuration port parameter interface example analysis code content simultaneous multiple environment article network service different host value interest action Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Tech Info MariaDB Shulou Technology vpn