A PHP/MySQL driven chat using sockets, This is the most basic example of how to have a MySQL interaction with a socket powered chat.
This uses Rachet for the Socket server: https://github.com/cboden/Ratchet
You should be comfortable using composer and knowledge of PSR standards.
What I have done here is very simple, I have set up a simple chat page where you can input content, it does not currently load any messages stored on the DB but will display messages sent and received when connected to the chat server.
To learn how to set it up please run through the tutorial on the Rachet website: