PHP Classes
elePHPant
Icontem

PHP MySQL Websocket Chat: Websocket chat that stores messages in MySQL

Recommend this page to a friend!
  Info   View files Documentation   Videos Videos   View files View files (14)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-02-12 (10 months ago) RSS 2.0 feedStarStarStarStar 65%Total: 783 This week: 9All time: 4,221 This week: 74Up
Version License PHP version Categories
mysql-websocket-chat 1.3MIT/X Consortium ...5HTTP, PHP 5, Databases, Chat
Description Author

This package can Websocket chat that stores messages in MySQL using PDO.

It takes HTTP Websocket connections to handle chat messages exchanged between users in a chat room.

It also supports exchanging messages privately between users.

Recommendations

What is the best PHP chat room class?
I need a simple chat package

php mysql websocket chat
I need to create realtime user to user chat

Innovation Award
PHP Programming Innovation award nominee
September 2016
Number 2


Prize: One big elePHPant Plush Mascott
Websockets are great for implementing interactive Web applications that require bidirectional communication between the browser and the server, like for instance chat systems.

This package implements a Websockets based chat system that can store messages in databases, so they can be accessed later if the users were not able to receive them when the messages were sent.

Manuel Lemos
  Performance   Level  
Name: Johnny Mast <contact>
Classes: 7 packages by
Country: The Netherlands The Netherlands
Age: 35
All time rank: 194656 in The Netherlands The Netherlands
Week rank: 52 Up3 in The Netherlands The Netherlands Up
Innovation award
Innovation award
Nominee: 3x

Details

Code Triagers Badge

MYSQL WEBSOCKET CHAT

Welcome to this hackaton project i created for user hrushi on phpclasses.org. The idea was to create a websocket chat application that could be logging to a database. So here is what you need to get this up and running. *Please note* the minimum required php version is 5.6 this is not because it wanted this but its because of the dependencies this project has.

Step 1: install composer

First thing you is installing composer on to your system. You can get composer here. Don't worry it might seem intimidating but its really not.

Step 2: Install the project

If you download this package in a zip file from phpclasses.org you will have to extract the zip package to a location of your liking. Then CD into that directory and execute the following command on your prompt.

In this example i am using a mac so my prompt will display different then you if you are on windows. Don't worry about that to much and execute the following command.

$ cd chat
$ composer install

On the other hand with composer installed you could use a more confidant method by installing the project via the composer create-project option. This will automatically download and install the project into the chat directory.

$ composer create-project johnnymast/mysql_websocket_chat chat

This will now download the whole project (and its dependencies) for you so you can run it.

Step 3: Configure the server

This server can run with or without a database. By default i have disabled the use of a database server but you can enable it by switching the ENABLE_DATABASE to true in the includes/config.php file. *Please note* if you enable the database make sure you update the credentials as well (see other defines).

Also if you enable the database make sure you have imported database.sql into your database.

Step 4: Fire up the server

CD in to the chat directory and fire up the server.

$ cd chat
$ php ./server.php

When you see no output and the command seems to hang that's when you know its running.

Step 5: Point a webserver to the chat directory

In the chat directory you will find index.php. This file will be the client for your chat application. Make sure you set any webserver its document root to this location.

Step 6: Chat away!

Now open up 2 chat tabs and point them to localhost (or maybe a virtual host you configured) and chat away with your self.

Author

mysql_websocket_chat is created and maintained by Johnny Mast. For feature requests or suggestions you could consider sending me an e-mail.

License

mysql_websocket_chat is released under the MIT public license.

<https://github.com/johnnymast/mysql_websocket_chat/blob/master/LICENSE.md>

Enjoy

Oh and if you've come down this far, you might as well follow me on twitter.

  Files folder image Files  
File Role Description
Files folder imagecss (2 files)
Files folder imageincludes (1 file, 1 directory)
Files folder imagejs (2 files)
Accessible without login Plain text file CHANELOG.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file database.sql Data Auxiliary data
Accessible without login Plain text file index.php Appl. Application script
Accessible without login Plain text file LICENSE.md Lic. License text
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file server.php Appl. Application script

  Files folder image Files  /  css  
File Role Description
  Accessible without login Plain text file starter-template.css Data Auxiliary data
  Accessible without login Plain text file style.css Data Auxiliary data

  Files folder image Files  /  includes  
File Role Description
Files folder imageclasses (2 files)
  Accessible without login Plain text file config.php Conf. Configuration script

  Files folder image Files  /  includes  /  classes  
File Role Description
  Plain text file Chat.php Class Class source
  Plain text file Database.php Class Class source

  Files folder image Files  /  js  
File Role Description
  Accessible without login Plain text file interface.js Data Auxiliary data
  Accessible without login Plain text file websockets.js Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:783
This week:9
All time:4,221
This week:74Up
 User Ratings  
 
 All time
Utility:93%StarStarStarStarStar
Consistency:93%StarStarStarStarStar
Documentation:87%StarStarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:65%StarStarStarStar
Rank:789