PhpStorm + Xdebug =页面未加载

Mat*_*ias 16 php xdebug phpstorm

首先,有一些xdebug信息:

Xdebug installed: 2.2.0rc1
Server API: Apache 2.4 Handler Apache Lounge
Windows: yes - Compiler: MS VC9 - Architecture: x86
Zend Server: no
PHP Version: 5.4.0
Zend API nr: 220100525
PHP API nr: 20100525
Debug Build: no
Thread Safe Build: yes
Configuration File Path: C:\Windows
Configuration File: C:\Uniserver\UniServer\usr\local\php\php.ini
Extensions directory: C:\Uniserver\UniServer\usr\local\php\extensions

You're already running the latest Xdebug version
Run Code Online (Sandbox Code Playgroud)

一切都很好看.这就是我的php.ini的样子:

[Xdebug]
zend_extension=C:\Uniserver\UniServer\usr\local\php\extensions\php_xdebug-2.2.0RC1-5.4-vc9.dll
xdebug.remote_host=localhost
xdebug.remote_port=9123
xdebug.idekey=PHPSTORM
xdebug.remote_mode=req
xdebug.remote_handler=dbgp
xdebug.remote_enable=1
xdebug.remote_connect_back=0
xdebug.remote_autostart=0
xdebug.remote_log="C:\Uniserver\UniServer\usr\local\php\extensions\tmp\log.log"
xdebug.overload_var_dump=1
xdebug.trace_format=0
xdebug.show_exception_trace=0
xdebug.default_enable=0
Run Code Online (Sandbox Code Playgroud)

现在,我将尝试使用PhpStorm进行调试.首先我转到Settings-> PHP-> Servers并添加:

Name: localhost
Host: localhost
Port: 8080
Debugger: Xdebug
Run Code Online (Sandbox Code Playgroud)

(是的,我的网站在端口8080上运行,否则我与我正在使用的其他软件发生冲突.)然后我创建一个新的运行/调试配置:

PHP Remote Debug
Name: local
Servers: localhost
Ide key(session id): PHPSTORM
Run Code Online (Sandbox Code Playgroud)

我还使用此工具创建了一个启动/停止调试书签:http://www.jetbrains.com/phpstorm/marklets/index.html

好的,一切都准备好了,所以我点击了PhpStorm中的Debug按钮.

我项目的主页位于http:// localhost:8080/Project/page/Home.php,所以我在那里导航.页面加载.我点击书签栏中的开始按钮,重新加载,页面保持空白...

当我在项目中的home.php文件中添加断点并再次重新加载时,断点就会被击中!我可以跨过,走进去......显示所有的值..这没有任何问题.但是当我查看所有断点,或点击Resume Program,并返回浏览器时,页面完全空白.HTML代码如下所示:

<html><head><style type="text/css"></style></head><body></body></html>
Run Code Online (Sandbox Code Playgroud)

到底是怎么回事?为什么我正在调试的页面没有被渲染?踩过代码可以工作,所有的php和html都在执行,但最后我的浏览器中没有显示任何内容.我打算在一个位于文件/Project/class/Account.php中的函数上使用Xdebugger,但是如果没有按下我的主页上的按钮,我就无法到达那里.

为什么不使用你说的Xdebug代理?可能解决任何问题?好吧,每当我尝试设置一个时,我都会收到此错误:

Xdebug代理:无法连接到'localhost:9123'上的xdebug代理

即使我的Xdebug代理配置正确:

IDE key: PHPSTORM
Host: localhost
Port: 9123
Run Code Online (Sandbox Code Playgroud)

谁能告诉我发生了什么事?我真的需要这个调试器,因为某些功能因某些原因无法正常工作,而且它让我疯狂.我需要检查传递的变量以及它们发生了什么.

编辑

额外信息:当我完成所有代码时,调试器会说:

Waiting for incoming connection with ide key 'PHPSTORM'
Run Code Online (Sandbox Code Playgroud)

这可能是我的页面没有加载的原因吗?

编辑编辑

好的,我也可以开始监听PHP Debug Connections,而不是点击调试按钮.这也有效!我的断点被击中了,我可以介入......但同样的问题仍然存在:我的网页保持空白,我的调试器最后说"断开连接".问题在任何浏览器中都存在.

编辑编辑

我在调试时发现了一些非常奇怪的东西...我可以直接进入我的代码,直到我点击获取我的数据库实例的函数.Database类看起来像这样:

class Database
{
    private static $instance = null;
    private static $conn;

    private function __construct()
    {
        try {
            self::$conn = new mysqli('localhost', 'root', 'root', 'database', '3308');
        } catch (Exception $ex) {
            $errorpager = new CustomPageGenerator();
            $errorpager->generateErrorPage("Connection to database failed. Please try again later.");
        }
    }

    public static function getInstance()
    {
        try {
            if (self::$instance == null) {
                self::$instance = new Database();
            }
            return self::$instance;
        } catch (Exception $ex) {
            $errorpager = new CustomPageGenerator();
            $errorpager->generateErrorPage("Connection to database failed. Please try again later.");
            return false;
        }
    }

    public function query($sql)
    {
        try {
            return self::$conn->query($sql);
        } catch (Exception $ex) {
            $errorpager = new CustomPageGenerator();
            $errorpager->generateErrorPage("Connection to database failed. Please try again later.");
            return false;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我觉得我的数据库类可能与此问题有关...每次我点击getInstance()函数时,调试都会暂停,我在Google Chrome中遇到net :: ERR_CONNECTION_RESET错误.这可能是问题吗?

hak*_*kre 0

根据您的描述,xdebug 远程调试是有效的。

很难说为什么 HTML 返回到浏览器(而不是您所期望的)。您是否尝试过使用稳定版本的 xdebug?