I am trying to implement simple notification system in Yii2. I have a list of Records populated in ListView. I would like to allow users to vote for this records. Only once per Record. Also the Author of each record must be notified (smth like new incoming emails) about who voted for his Record. What is the easiest way to implement this in Yii2? Thanks for an advice!
With php only you can't do that, you need to have js at some point.
Solution One could be, from user B side you keep asking the server after certain time (using ajax), if anything(event) happened. If it does return the result with that ajax and update the page. But then again this is not a very good practice.
If you really want a Real Time update, you might want to use socket.io. Then again using php socket is a bad idea.
So here comes the Solution Two: yii2 + redis + nodejs + socket
redis will do the communication between yii2 and nodejs. The idea is, if anything (event or update) happens yii2 will publish a event
with associate data
to redis channel
and nodejs which is listening to that channel will catch that event and send the data (or update) to client using socket.
Here is a real time chat application tutorial using yii2+redis+nodejs+socket.