PHP debug配置
&防止Apache 500 Nginx 404
环境选择
Windows
Mac可用
Linux仅供参考
PHPStudy
选择原因:
可以直接安装composer(MacOS版中无法使用);
方便配置
Apache or Nginx
VSCode or PHPStorm
优点:
PHPStorm,点击方法直接跳转
VSCode 搜索功能与快速预览更好用
缺点:
PHPStorm 贵,这是我的问题
VSCode框架类代码跨文件没法跳转
浏览器+Xdebug helper
浏览器选择:能装Xdebug helper即可
PHPStudy 配置
软件设置
php.ini设置
在以上设置基础上可只添加(下面代码块1)
自用全部内容如下(下面代码块2)
xdebug.remote_enable=On
xdebug.remote_autostart = On
[Xdebug]
zend_extension=D:/phpstudy_pro/Extensions/php/php7.3.9nts/ext/php_xdebug.dll
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.auto_trace=On
xdebug.trace_output_dir=D:/phpstudy_pro/Extensions/php_log/php7.3.9nts.xdebug.trace
xdebug.profiler_enable=On
xdebug.profiler_output_dir ="D:\phpstudy_pro\Extensions\tmp\xdebug"
xdebug.remote_enable=On
xdebug.remote_autostart = On
xdebug.remote_host=localhost
xdebug.remote_port=9003
xdebug.remote_handler=dbgp
;控制var_dump输出深度
xdebug.var_display_max_children=999
xdebug.var_display_max_data=999
xdebug.var_display_max_depth=999
查看扩展是否安装
防止调试超时
在调试php代码时,调试会在一分钟左右终止
调试超时原因:http server 与PHP cgi通信超时
配置文件
php.ini
更改php.ini如下内容
max_execution_time = 3600
Apache
打开apache配置文件httpd.conf注释掉如下,并添加一行。
# Various default settings
Include conf/extra/httpd-default.conf 将注释去掉
Include conf/extra/httpd-fcgid.conf 添加此行
更改httpd-default.conf如下内容
Timeout 3600
KeepAlive On
MaxKeepAliveRequests 0
KeepAliveTimeout 3600
在extra目录下创建httpd-fcgid.conf,写入如下内容
ProcessLifeTime 3600
FcgidIOTimeout 3600
FcgidConnectTimeout 3600
FcgidOutputBufferSize 128
FcgidMaxRequestsPerProcess 1000
FcgidMinProcessesPerClass 0
FcgidMaxProcesses 16
FcgidMaxRequestLen 268435456
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000
IPCConnectTimeout 3600
IPCCommTimeout 3600
FcgidIdleTimeout 3600
FcgidBusyTimeout 60000
FcgidBusyScanInterval 120
AddHandler fcgid-script .php
Nginx
nginx.conf下http{}中,添加
fastcgi_connect_timeout 60000;
fastcgi_read_timeout 60000;
fastcgi_send_timeout 60000;
VSCode配置
插件
或者:PHP Extension Pack, 包含以上两个
PHP Debug
PHP Intelphense
VSCode 运行-->打开配置,打开即添加配置,使用VSCode默认配置即可
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9003,
},
]
}
文件-->首选项-->配置-->settiong.json
settiong.json添加php路径
{"php.validate.executablePath": "D:\\phpstudy_pro\\Extensions\\php\\php7.3.9nts\\php.exe",
}
PHPStorm
浏览器配置
插件Xdebug helper
IDEKEY选择PHPSTORM
开启:
PHPStorm设置
File->Settings
开启监听,此为监听状态
打开代码,断点调试,访问页面,弹窗如下,Accept即可
server会自动配置
可选配置PHP位置
参考
本文为 独立观点,未经允许不得转载,授权请联系FreeBuf客服小蜜蜂,微信:freebee2022
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
相关推荐
文章目录