I have a market prices table, it updated every millisecond from a third-party service. I need something to display the live prices to my HTML view, I don't want to use ajax
2 Answers
Asynchronous JavaScript probably is the easiest and lowest latency (best) solution although it still won't likely provide you to the millisecond accuracy.
Presenting the raw data source in a html frame that is repeatedly refresh via JavaScript may be an option depending on formatting needs but this has it's own challenges and is a bit of a hack.
You might be able to achieve this with static site generation task (rebuild) scheduling but you would be looking at even larger latency in that case, people would also need to refresh the page to see the updated data unless you refresh the page on an interval with this solution.
When dealing with markup the content will either need to be refreshed by JavaScript or by browser refresh.

- 297
- 2
- 9
To display data live, yes! websockets are the answer. Though you can't run them on the same server your default Laravel server relies. You'll need to create a different server via Artisan console or Task scheduler listening on a different port. Make sure your hosting provider supports the ability to listen over other ports than 80/443. You may need a VPS or something serverless to run such application.
The only reliable websocket PHP library which I know it has good integrity with Laravel is Ratchet.
Though I advise NodeJS with SocketIO when it comes to websocket applications.

- 2,161
- 1
- 14
- 39