Enable Server-Side Events (SSE) / Streaming with PHP by default

Hey @TigrouMeow - thanks for starting this feature request!

The engineering team talked it over, and this is possible in Local today. The nginix configuration just needs to be updated and you’re good to go. Here are the steps we took to see it working:

  1. Using Site Domains router mode in Local, Create a new site
  2. Add your sse.php script to ~/Local Sites/sitename/app/public/sse.php
  3. Navigate to that script in the browser: http://sitename.local
  4. Note that the script waits for a bit, then outputs all the numbers. The intended behavior is to have each number show up one at a time, about a second apart
  5. Edit /Applications/Local.app/Contents/Resources/extraResources/router-config/nginx.conf and add the below nginx config lines:
    proxy_set_header Connection '';
    proxy_http_version 1.1;
  6. Quit Local and restart it (this regenerates the router config file)
  7. Navigate to the script again in the browser (http://sitename.local) and note that the numbers come in, one at a time.

Shared with Zight

We can evaluate changing this default behavior, but we’ll have to do some research on any potential side effects… the good news is that with some quick changes, users can have this working in Local pretty easily!

1 Like