2

I am trying to get the datafeed from Kite Connect via async web socket. I think that I can use amphp/websocket-client library in my Laravel project but I am clueless where to begin.

How to integrate this library to get the data feed in my Laravel app?

How do I use the stream of data that keeps coming in non-stop?

Besto
  • 109
  • 1
  • 11
  • Laravel is a framework for serving requests... it boots up, serves and shuts down... You will need another persistant process to keep the connection alive and a way to have this streamed info into a storage that can be accessed by the Laravel requests... A little more context would help ... what are you trying to do in the end? – Serge May 07 '18 at 15:34
  • 1
    Kite Connect is a trading platform which gives stock prices (via web sockets) which we can analyze using php's trader functions and we can place orders for buying/selling stocks. Your reply has made things a bit more clear that the framework boots and shuts down - this is why I could not understand where to handle the stream. Since the application's sole purpose is just this (and it is not a large app) please suggest how do I go about it. Should I use something other than Laravel? – Besto May 07 '18 at 17:16
  • This requires some thought... What will be the user interface? So given that you would have a simple app that fronts and displays the stock info, this could use Laravel... However, the task that does the real time analysis will be a separate program... storing its data in a database which the Laravel app can display to the users... The background process (the one that runs all the time) can be done in PHP however I would look into Node for that part... You could have a php script run as a deamon that does it too... but it is not really a good application for PHP in my view. – Serge May 07 '18 at 18:42
  • Thank you Serge. Your last line is worth pondering upon. I will explore Node and see if there is a simple solution. I like Javascript but learning the whole Node stack seems a bit overkill for me. Anyways I will come back here and let you know my solution and for others to benefit. Thanks once again :) – Besto May 08 '18 at 05:45
  • I might be late but i have found the solution for this. [here](https://stackoverflow.com/questions/62791258/get-websocket-data-in-laravel-controller/62819125#62819125) – Dinesh Naik Jul 09 '20 at 16:21

0 Answers0