首先,先了解一些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
一切看起来都很好。这是我的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
现在,我将尝试使用PhpStorm进行调试。首先,我转到“设置”->“PHP”->“服务器”,并添加以下内容:
Name: localhost
Host: localhost
Port: 8080
Debugger: Xdebug
(是的,我的网站在端口8080上运行,否则我与正在使用的其他软件发生冲突。)然后我创建了一个新的运行/调试配置:
PHP Remote Debug
Name: local
Servers: localhost
Ide key(session id): PHPSTORM
我还使用此工具创建了一个启动/停止调试书签:http://www.jetbrains.com/phpstorm/marklets/index.html
好的,一切看起来都准备好了,所以我点击了PhpStorm中的“调试”按钮。
我的项目的主页位于http://localhost:8080/Project/page/Home.php,所以我在那儿导航。页面加载。我点击书签栏中的开始按钮,重新加载,页面仍然空白...
当我在项目中的home.php文件上添加断点并再次重新加载时,该断点会命中!我可以跨步,进入,...显示所有值。但是当我查看所有断点或单击“恢复程序”,然后返回浏览器时,页面完全空白。 HTML代码如下所示:
<html><head><style type="text/css"></style></head><body></body></html>
到底是怎么回事?为什么我正在调试的页面未呈现?单步执行代码后,所有的php和html都将被执行,但最终在我的浏览器中什么也没有显示。我计划在文件/Project/class/Account.php中的函数上使用Xdebugger,但是如果不按主页上的按钮就无法到达那里。
为什么不使用您说的Xdebug代理?可以解决任何问题吗?好吧,每当我尝试设置一个时,都会出现此错误:
Xdebug代理:无法连接到“localhost:9123”上的xdebug代理
即使我的Xdebug代理配置正确:
IDE key: PHPSTORM
Host: localhost
Port: 9123
谁能告诉我发生了什么事?我真的需要这个调试器,因为某些功能由于某种原因无法正常运行,这使我发疯。我需要检查传递了哪些变量以及它们发生了什么。
编辑
额外信息:完成所有代码后,调试器会说:
Waiting for incoming connection with ide key 'PHPSTORM'
这可能是我的页面无法加载的原因吗?
编辑EDIT
好的,不用点击调试按钮,我也可以开始收听PHP Debug Connections。这也一样!我的断点被击中,我可以介入...但是同样的问题仍然存在:我的网页仍然空白,并且调试器最后说“Disconnected”。该问题在任何浏览器中仍然存在。
编辑编辑编辑
我在调试时发现了其他很奇怪的东西...我可以很好地进入代码,直到点击获取数据库实例的函数。 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;
}
}
}
我感觉到我的数据库类可能与此问题有关...每次我碰到getInstance()函数时,调试都会突然停止,并且在Google Chrome中出现net::ERR_CONNECTION_RESET错误。这可能是问题吗?
最佳答案
根据您的描述,xdebug远程调试有效。
为什么很难将HTML返回到浏览器(而不是您期望的)。您是否尝试过使用稳定版本的xdebug?
关于php - PhpStorm + Xdebug =页面未加载,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10125216/