Webchat updating when other user sends message

Im building a webchat using php and json. I know thats not the best solution but works for what im building.

So far users can send their messages and they get saved and displayed in the chat.

However the users need to manualy update the website to get new messages shown.

Is there anyway to detect file changes in php so that i can reload or rebuild the website.

Maybe checking the array length in the php file and then restarting the process again.

Can anybody please help me 🙂