Fork me on GitHub

phpstorm开启debug断点调试模式

查看php版本

查看自己php的版本,使用:phpinfo() 函数

<?php
echo phpinfo();

Xdebug

Xdebug: Support — Tailored Installation Instructions
右击查看index.php源代码
image

并复制到Xdebug中
image

点击分析查看分析结果
image

修改php配置文件

vi /opt/homebrew/etc/php/7.4/php.ini

#安装完Xdebug自带
zend_extension = xdebug
#添加部分
xdebug.mode=debug
xdebug.remote_enable = On
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "localhost"
xdebug.remote_mode = "req"
xdebug.remote_port = 9000
xdebug.idekey = "PHPSTORM"

重启php-fpm

直接重启php环境,php-fpm也会一起重启,在刷新一下php网站的环境信息,里面就会有xdebug的描述,即配置成功

#重启php
brew services restart php@7.4

image

webstorm配置

file->settings->PHP->Debug,9000端口是php.ini中Xdebug设置里面xdebug的端口,如果本地已经被占用了可以修改
image
idekey 必须要和xdebug配置的一致
image

添加php web Page配置

添加php web Page
image
添加server
image

特重要步骤

必须要去验证下是否可用,它会告诉你当前存在的问题或者是否已经可用,按照提示去修复即可。
image

测试

image

调试thinkphp

添加PHP Web Page
image
修改nginx.conf配置文件

    server {
        listen       8028;
        server_name  localhost;
        #root要写在外面,不然$document_root读不到
        root   /opt/homebrew/var/www/tp/public;

        location / {
            index  index.html index.htm;
	        # 主要是这个是新加的起作用的,
            if (!-e $request_filename) {
	            rewrite  ^(.*)$  /index.php?s=/$1  last;
		        break;
	        }
        }

        location = /50x.html {
            root   html;
        }

        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9999;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }

    }

重启nginx和fpm

#重启fpm
killall php-fpm
php-fpm -D
#重启nginx
brew services restart nginx

image

测试

public下面的info.php读取成功
image
调试接口成功
image
image

posted @ 2024-02-26 21:16  秋夜雨巷  阅读(185)  评论(0编辑  收藏  举报