pocketjs is a barebones WebSocket library for implementing realtime applications in PHP and JavaScript.
Event-driven, minimalistic design. Created for rubbr.
Why pocketjs?
Many web developers have many existing dynamic web applications currently deployed, but they require a solution for seamless realtime integration, rather than a framework around/in which to architect their entire application. There are many existing options, such as node.js/socket.io and Firebase, but many require a dramatic shift to an unfamiliar and heavy framework, or essentially just having envisioned and built the project for that framework in the first place. pocketjs is a lightweight, encapsulated, and straightforward library for incorporating realtime updates into an existing web app (preferably written in PHP, but any language should be compatible).
Visit github.anuv.me/pocketjs.
pocketjs blends well into existing web frameworks:
- WebSocket Server - pocketjs
- Handles WS/WSS requests
- Runs on port 8000/8443 (or custom)
- Backgrounded PHP process of a pocketjs script
- ie.
nohup php
on Linux, or other
- ie.
- Receives and sends updates to/from clients
- WebSocket Client - pocketjs
- Provided by web server over HTTP/HTTPS
- Connects to WebSocket server over WS/WSS
- Receives and sends updates to/from server
- Web Server - all are compatible
- Apache, NGINX, node.js, etc.
- Handles HTTP/HTTPS requests
- Runs on port 80/443, or with a reverse proxy
- Serves static/dynamic HTML/CSS/JS content
- Provides WebSocket client for pocketjs server
The WebSocket server runs independently from the Web Server, and can easily be appended to an existing application.
Regarding program structure, pocketjs utilizes an event-driven flow model to simplify operations as much as possible within the bounds of PHP.
Documentation and tutorials: Check out docs and tutorials at github.anuv.me/pocketjs/docs. Here you can find a getting started guide, a tutorial on the basics of a typical pocketjs application, and documentation for each function of both the client and server.
View a live demo!
- View live demos online at github.anuv.me/pocketjs/demos
- View a chat demo alongside code online at github.anuv.me/pocketjs/#hook
- Host your own local chat app
pocketjs is compatible with many libraries and frameworks, as it functions on its own.
pocketjs is released under the MIT License
2016