Using vscode edit to debug PHP configurator and vscode breakpoint to debug PHP

Time:2019-11-5

The previous PHP debugging tools, such as Zend studio or phpclipse, are slow to run. It’s still easy to use.
 

Software name:
Visual studio code 64 bit v1.28.1 official latest installation
Software size:
42.0MB
Updated:
2018-10-18

1. First, Download vs Code on the official website at https://code.visualstudio.com/, and then install it directly.

2. See https://marketplace.visualstudio.com/items? Itemname = felixfbecker.php-debug for the installation steps of PHP debug

For details: press CTL + shif + X or click the red “extension tag”, and enter Xdebug to install
 


 

3. In the menu bar: File preferences configuration
 


 

Pop up the following window and add “PHP. Validate. Executablepath”: “D: / usr / local / PHP. Exe”

//Put settings in this file to override the default settings  
{  
    "php.validate.executablePath": "D:/usr/local/php/php.exe",  
    "editor.fontSize": 12  
  
}

4. You must open your PHP project directory before you can set debug


 

1. Click the gear, select PHP –, and select listen for Xdebug

(profile content does not need to be moved)


 

 

5. Open the PHP file, press F9 on the specified line to set the breakpoint, and then start debugging.

Test whether the configuration is correct. In the CMD window, execute netstat – an to see if the local machine has a listening 9000 port.
 

6. Visit the debuggable web page
 

Appendix:

Vs Code modify shortcut binding: File preferences keyboard shortcut  
[{  
    "key": "f8",  
    "command": "workbench.action.debug.stepOver",  
    "when": "inDebugMode"  
},{  
    "key": "f7",  
    "command": "workbench.action.debug.stepInto",  
    "when": "inDebugMode"  
}  
]

 

Vscode breakpoint debugging PHP

Today, I’m going to write a little bit of PHP. It’s multi-level nesting. The logic is a little complicated. I used to debug it by logging. We. Neter were spoiled by vs, so I tried to add debug to PHP in vscode

1. Install the integrated environment package phpstudy

Software name:
Phpstudy 2018 (PHP running environment installation package) for Linux official + Full Version (with installation method)
Software size:
128MB
Updated:
2018-02-28

Start the Apache server, and then – > other options menu – > My homepages enter phpinfo
Find the PHP version installation directory and find Xdebug. If not, add this label

[XDebug]
xdebug.profiler_output_dir=”D:\phpStudy\tmp\xdebug”
xdebug.trace_output_dir=”D:\phpStudy\tmp\xdebug”
zend_extension=”D:\phpStudy\php\php-5.6.27-nts\ext\php_xdebug.dll”
xdebug.remote_enable = 1
xdebug.remote_autostart = 1

Draw a key point. The last two sentences must be added. Remember that you can’t enter the breakpoint if you don’t add them

Then vscode, go to the official website to download and install it, and then search the three plug-ins in the store

Then you can start debugging your PHP code. F5 starts….

And still can’t run, right?

Finally, add PHP path to vs,

Now press debug to run it… Whether you can or not, I can