This is a bare bones example of how Vanilla Javascript + PHP works with websockets
Well this example shows you bare bones how a php web socket server works, and how the client interacts with it. I am quiet tired of using libraries, and thinking of this as magic, I want to KNOW how it works.
- Download XAMPP or equivalent
- Go to php.ini set these two values, ensure they are enabled:
-
TO:
-
max_execution_time=0
-
FROM:
-
max_execution_time=120
-
TO:
-
extension=sockets
-
FROM:
-
;extension=sockets
-
- Start or restart your apache web server on XAMPP
- Start mysql server and use any client to paste SQL code from db.sql file. It will create the database and schema
- Go to localhost or 127.0.0.1, in one tab and go to server.php from the web browser directory to start the websocket server, it will continuously circle leave this tab running
- In a new tab go to localhost or 127.0.0.1, and go to index1.php
- In a new tab or window side by side, go to localhost or 127.0.0.1, and go to index2.php
- Click the button on index1.php, see that it updates on index2.php