Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of remote Multi-session debugging in PHP

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report