A minimal demo of io->of('/path'): two fully independent communication
channels (/public and /admin) sharing the same server and port. A message
sent in one namespace never reaches a client connected to the other, even
though both use the exact same Socket.IO connection endpoint.
This is a different kind of grouping than rooms -- a namespace is
a separate channel you connect to (io(url + '/admin')), not a subset of
clients within a single connection you can join and leave at will.
| Service | Port |
|---|---|
| Web (demo UI) | 2035 |
| Socket.IO | 2034 |
docker compose up --build namespacesThen open http://localhost:2035.
cd examples/namespaces
php start.php startThen open http://localhost:2035.
- Open the page in two tabs. Connect both to Public.
- Send a message from one tab -- it appears in the other.
- Open a third tab, connect it to Admin instead.
- Send a message from the Public tabs -- the Admin tab never sees it (and vice versa). Check the server's terminal output: every connection and message is logged with which namespace it belongs to.