在 PhpStorm 调试应用程序中启动时,我遇到了一些问题。
当我访问调试应用程序的 URL 时,会为通知系统生成额外的事件源请求 (SSE)。但是当调试工作时,它会导致我无法刷新页面的问题,它只是无限期地加载 - 我没有任何断点可以确定。在我停止调试会话后立即加载。
这是怎么回事?我可以以某种方式禁用此特定 URL 的 xdebug 吗?
这些通知的代码如下所示:
public function moreAction()
{
ob_start();
$maxId = $this->request->getQuery('maxId', 'int');
header('Cache-Control: no-cache');
header("Content-Type: text/event-stream\n\n");
while (1) {
$result = $this->notificationService->more($maxId);
if (count($result) > 0) {
foreach ($result as &$row) {
if (!empty($row['data'])) {
$row['data'] = json_decode($row['data'], true);
}
}
$maxId = $result[0]['id'];
echo "event: message\n";
echo "data:".json_encode($result);
echo "\n\n";
$this->doFlush();
}
sleep(5);
}
}
protected function doFlush()
{
if (!headers_sent()) {
// Disable gzip in PHP.
ini_set('zlib.output_compression', 0);
// Force disable compression in a header.
// Required for flush in some cases (Apache + mod_proxy, nginx, php-fpm).
header('Content-Encoding: none');
}
// Fill-up 4 kB buffer (should be enough in most cases).
echo str_pad('', 4 * 1024);
// Flush all buffers.
do {
$flushed = @ob_end_flush();
} while ($flushed);
@ob_flush();
flush();
}