title: How do I implement Server Sent Events in PHP?
body: <p>I had set up a server sent event script with php and a while loop, I did not want for the script to have to keep closing and have to repoll so I put it all in a while loop.</p>
  
  <p>The issue was that the script was getting stuck and I had to abandon that route and I went with a node.js websocket backend instead.</p>
  
  <p>My question is, if I ever went back to making a server sent event php script, how do I implement it?<br>
  <code>while</code> loops do not seem to cut it as it hangs the script, and if it is just connecting and disconnecting every second, it is no different than long polling, so how do I create a PHP script that will not hang, while also sending over the SSE messages?</p>