Real Time Notifications to Client

I’m creating Yii2 app and it will be alerting Users each time new data (inserted via AR) is inserted. I know I can register handler to Events to AR but what are options available for Yii2 or even PHP that can easily integrate with Yii2 to notify user?

I know I could use JS and Timer to check those things, but I save that as a last resort.


Take a look at PHP Websockets.


checked http// and I see somehow I need it as a server. Their first example which uses terminal just made me crazy.

Do I need to run it each time server reboots for example? Do I miss something?

Seems to be impossible for now without external PHP “daemon” like mentioned above. I don’t want to do NodeJs stuffswith

Is there a way to achieve a semi-realtime way to do it (a delay of 1min or less) with PHP somehow without AJAX/Polling?

You can start simple console php script as a websocket server. I don’t have much experience with it but there are working examples like

and many more.