|
| 1 | +# PHP |
| 2 | + |
| 3 | +## phpstudy + VSCode 环境配置 |
| 4 | + |
| 5 | +* 用phpstudy安装php、apache/nginx,还可能用到mysql |
| 6 | + |
| 7 | +* phpstudy -- 软件管理 -- 选择安装的PHP设置 -- 打开调试组件 |
| 8 | + |
| 9 | + (记住这里的端口9000,也可以修改) |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +* 在php.ini中添加配置 |
| 14 | + |
| 15 | + ```apl |
| 16 | + [Xdebug] |
| 17 | + zend_extension=D:/phpstudy_pro/Extensions/php/php7.3.4nts/ext/php_xdebug.dll |
| 18 | + xdebug.collect_params=1 |
| 19 | + xdebug.collect_return=1 |
| 20 | + xdebug.auto_trace=On |
| 21 | + xdebug.trace_output_dir=D:/phpstudy_pro/Extensions/php_log/php7.3.4nts.xdebug.trace |
| 22 | + xdebug.profiler_enable=On |
| 23 | + xdebug.profiler_output_dir=D:/phpstudy_pro/Extensions/php_log/php7.3.4nts.xdebug.profiler |
| 24 | + xdebug.remote_enable=On #修改为On |
| 25 | + xdebug.remote_autostart = On #添加 |
| 26 | + xdebug.remote_host=localhost |
| 27 | + xdebug.remote_port=9000 #修改成对应端口 |
| 28 | + xdebug.remote_handler=dbgp |
| 29 | + ``` |
| 30 | + |
| 31 | +* vscode安装``PHP Extension Pack`插件,里面包括`PHP Debug`和`PHP IntelliSense` |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | +* 修改vscode设置,填写php和xdebug的地址 |
| 36 | + |
| 37 | +```json |
| 38 | + "php.executablePath": "D:/install/phpstudy_pro/Extensions/php/php7.4.3nts/php.exe", |
| 39 | + "php.debug.executablePath": "D:/install/phpstudy_pro/Extensions/php/php7.3.4nts/ext/php_xdebug.dll", |
| 40 | +``` |
| 41 | + |
| 42 | +* 对vscode的调试页面进行配置 |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +```json |
| 47 | +{ |
| 48 | + "version": "0.2.0", |
| 49 | + "configurations": [ |
| 50 | + { |
| 51 | + "name": "Listen for Xdebug", |
| 52 | + "type": "php", |
| 53 | + "request": "launch", |
| 54 | + "port": 9000 |
| 55 | + }, |
| 56 | + { |
| 57 | + "name": "Launch currently open script", |
| 58 | + "type": "php", |
| 59 | + "request": "launch", |
| 60 | + "program": "${file}", |
| 61 | + "cwd": "${fileDirname}", |
| 62 | + "port": 9000, |
| 63 | + "runtimeArgs": [ |
| 64 | + "-dxdebug.start_with_request=yes" |
| 65 | + ], |
| 66 | + "env": { |
| 67 | + "XDEBUG_MODE": "debug,develop", |
| 68 | + "XDEBUG_CONFIG": "client_port=${port}" |
| 69 | + } |
| 70 | + } |
| 71 | + ] |
| 72 | +} |
| 73 | +``` |
| 74 | + |
| 75 | +* 打断点开始调试 |
0 commit comments