I would like to use xdebug in PHP to perform steps at breakpoint.

Asked 2 years ago, Updated 2 years ago, 404 views

I installed php xdebug on VSCode.I'd like to take steps.
Running > Start Debugging from the menu with a breakpoint will not stop you.

The current situation is as follows:


in the 1.xdebug configuration file (launch.json) StopOnEntry is true (set to stop at the first line when debugging starts)
pathMappings to "${c:/Apache24}":"${c:/Apache24/htdocs}"

The pathMappings c:/Apache24/htdocs contains the php you want to run.

2. Add the xdebug dll file downloaded from xdebug.org in the php.ini settings (Dynamic Extensions).


zend_extension=xdebug-3.0.1-7.4-vc15-x86_64

where xdebug-3.0.1-7.4-vc15-x86_64.dll is
It is located at C:\php-7.4.13\ext.

in php.ini extension_dir="C:/php-7.4.13/ext"
is configured as

I think that pathMappings setting in 1. is {path of server(=Apache)}:{path with local execution resources} but is that wrong?

For 2. , an extension of php is xdebug, and the dll required to run xdebug is
I think it's in C:\php-7.4.13\ext.
Does that mean that the dll is enabled in the php configuration file?

php apache vscode

2022-09-30 21:50

1 Answers

Create a Linux+Apache+php environment with SELINUX turned off as a Bridge Adapter VM in VirtualBox and
Install VSCode in your local environment and
Describes the same source in the VSCode workspace and server.
Assume that WebRoot on the server is /var/www/html and
Enter the Virtualbox ip from your browser and assume that the php site is available for viewing.

[Server side settings]

sudo yum-y install --enablerepo=remi-php72php-pecl-xdebug

sudo vi /etc/php.d/15-xdebug.ini

 [xdebug]
xdebug.default_enable=1
xdebug.idekey="vscode"
xdebug.remote_enable=1
xdebug.remote_port = 9000
xdebug.remote_autostart=1
xdebug.remote_host=<develop pc's IP>

sudo systemctl restart httpd.service

[VSCode side settings]

launch.json

{
    // Use IntelliSense to learn the available attributes.
    // Displays a description of an existing attribute by hovering.
    // For more information: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port"—9000,
            "pathMappings": {
                "/var/www/html": "${workspaceRoot}"
            }
        }
    ]
}


2022-09-30 21:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.