https://github.com/bornmajor/ultimate-websocket-app
This project illustrates how to use WebSocket in Hypertext Processor (PHP). It's a simple chat/messaging app that demonstrates the benefits of WebSocket over traditional polling, where the HTTP protocol remains open, allowing real-time updates without the need for constant refreshing.
https://github.com/bornmajor/ultimate-websocket-app
asynchronous-programming chat-app php ratchet-websocket-server websocket
Last synced: 2 months ago
JSON representation
This project illustrates how to use WebSocket in Hypertext Processor (PHP). It's a simple chat/messaging app that demonstrates the benefits of WebSocket over traditional polling, where the HTTP protocol remains open, allowing real-time updates without the need for constant refreshing.
- Host: GitHub
- URL: https://github.com/bornmajor/ultimate-websocket-app
- Owner: Bornmajor
- Created: 2024-06-19T16:38:53.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-06-19T16:51:58.000Z (12 months ago)
- Last Synced: 2025-02-01T19:12:08.021Z (4 months ago)
- Topics: asynchronous-programming, chat-app, php, ratchet-websocket-server, websocket
- Language: PHP
- Homepage:
- Size: 1.42 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# The Ultimate websocket App
This project illustrates how to use WebSocket in Hypertext Processor (PHP) using the Ratchet library. It's a simple chat/messaging app that demonstrates the benefits of WebSocket over traditional polling, where the HTTP protocol remains open, allowing real-time updates without the need for constant refreshing.## Problem Solving
### Traditional Polling
Traditional polling involves sending requests to the server at regular intervals to check for updates. This approach has several disadvantages:1. Increased Server Load: Constantly sending requests to the server increases its load and can lead to performance issues.
2. Higher Latency: There is a delay between the time when data is updated on the server and when it is received by the client.
3. Inefficiency: Many requests return without any new data, leading to unnecessary network traffic.
### WebSocket Solution
WebSocket solves these issues by maintaining an open connection between the client and server:1. Real-Time Updates: The server can push updates to the client instantly, reducing latency.
2. Reduced Server Load: Fewer requests are sent since the connection remains open, leading to more efficient use of resources.
3. Efficient Communication: Data is sent only when there are updates, reducing unnecessary network traffic.## Features
1. Send messages instantly to other users.
2. Generate profile avatars and usernames, stored in the database.
3. Real-time availability of users for chatting.## Getting Started
### To use this project:1. Install the Ratchet PHP library for WebSocketing.
2. Import the provided database located in the database/ folder.
3. Run the WebSocket server script (server.php) found under the async/ folder using the console.
## Usage
1. Clone the repository to your local environment.
2. Install Composer dependencies using composer install.
3. Import the database from the database/ folder.
4. Navigate to the async/ folder and run php server.php in your terminal to start the WebSocket server.
5. Open the project in your web browser to start using the chat app.## Dependencies
Ratchet PHP Library - For WebSocket functionality.# Demo
## Clip
https://github.com/Bornmajor/ultimate-websocket-app/assets/98744068/04965478-420c-4639-8709-ec8c710e8daa
## Screenshot

