README
Real-Time Multiplayer Rock Paper Scissors
A real-time multiplayer Rock Paper Scissors game built with PHP, JavaScript and Pusher. Players can create or join a private room using a shareable link and play with live updates.
Overview
This project implements a lightweight real-time game system where two players interact in a shared room. Game state is synchronized across clients using event-driven updates.
Features
- Create or join private game rooms
- Real-time synchronization between players
- Instant move updates and result calculation
- Room-based game state management
- Automatic room cleanup via script
- Modular backend structure (Controllers and Services)
Tech Stack
- PHP
- JavaScript
- Pusher (WebSocket-based communication)
- Docker
- Composer
Architecture
The backend is structured using a simple separation of concerns:
Controllershandle incoming requestsServicescontain business logic (room management, real-time events)Scriptshandle maintenance tasks such as cleaning inactive roomsPublicserves frontend assets and entry point
Game state is stored per room and updated through API calls. Changes are broadcast to connected clients using Pusher.
Project Structure
public/– frontend entry point and assetssrc/Controllers/– request handlingsrc/Services/– business logic and integrationsscripts/– maintenance scriptsincludes/– environment and bootstrap logic
Running Locally
Using Docker
docker build -t rock-paper-scissors .
docker run -p 8080:80 rock-paper-scissors
Then open: http://localhost:8080
Environment Configuration
Create a .env file with the following variables:
PUSHER_APP_ID=your_app_id
PUSHER_KEY=your_key
PUSHER_SECRET=your_secret
PUSHER_CLUSTER=your_cluster
Future Improvements
- Add authentication
- Persist game state in a database
- Add rematch functionality
- Improve frontend responsiveness
- Add automated testing
Connect with Me