{"id":19031945,"url":"https://github.com/johnnymast/mysql_websocket_chat","last_synced_at":"2026-03-17T11:33:44.668Z","repository":{"id":57000941,"uuid":"68401373","full_name":"johnnymast/mysql_websocket_chat","owner":"johnnymast","description":"Quickly get a websocket chat up and running","archived":false,"fork":false,"pushed_at":"2023-07-07T23:25:45.000Z","size":489,"stargazers_count":22,"open_issues_count":18,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-28T16:37:41.702Z","etag":null,"topics":["boilerplate","chat","composer-project","phpclasses","private-chat","project","ratchet","webserver","websocket-chat"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnnymast.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":"https://www.paypal.me/johnnymast"}},"created_at":"2016-09-16T17:39:58.000Z","updated_at":"2025-03-13T20:42:04.000Z","dependencies_parsed_at":"2024-11-08T21:38:04.277Z","dependency_job_id":null,"html_url":"https://github.com/johnnymast/mysql_websocket_chat","commit_stats":{"total_commits":134,"total_committers":2,"mean_commits":67.0,"dds":0.007462686567164201,"last_synced_commit":"d1dd4b784a2435b903bd7762924b03694f460364"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/johnnymast/mysql_websocket_chat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnnymast%2Fmysql_websocket_chat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnnymast%2Fmysql_websocket_chat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnnymast%2Fmysql_websocket_chat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnnymast%2Fmysql_websocket_chat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnnymast","download_url":"https://codeload.github.com/johnnymast/mysql_websocket_chat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnnymast%2Fmysql_websocket_chat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30622749,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T11:26:08.186Z","status":"ssl_error","status_checked_at":"2026-03-17T11:24:37.311Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boilerplate","chat","composer-project","phpclasses","private-chat","project","ratchet","webserver","websocket-chat"],"created_at":"2024-11-08T21:25:50.247Z","updated_at":"2026-03-17T11:33:44.652Z","avatar_url":"https://github.com/johnnymast.png","language":"PHP","funding_links":["https://www.paypal.me/johnnymast"],"categories":[],"sub_categories":[],"readme":"[![Code Triagers Badge](https://www.codetriage.com/johnnymast/mysql_websocket_chat/badges/users.svg)](https://www.codetriage.com/johnnymast/mysql_websocket_chat)\n![ESLint](https://github.com/johnnymast/mysql_websocket_chat/workflows/ESLint/badge.svg)\n![StyleLint](https://github.com/johnnymast/mysql_websocket_chat/workflows/StyleLint/badge.svg)\n![Phpcs](https://github.com/johnnymast/mysql_websocket_chat/workflows/Phpcs/badge.svg)\n\n# MYSQL WEBSOCKET CHAT\n\nWelcome to this Hackaton project I created for user hrushi on [phpclasses.org](http://www.phpclasses.org/recommend/754-I-need-to-create-realtime-user-to-user-chat.html). The idea was to create a web socket chat application\nthat 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 7.0- this is not because it wanted this but it is because of the dependencies this project has.\n\n\n# Step 1: install composer\n\nFirst thing you is installing composer on to your system. You can get composer [here](https://getcomposer.org/download/). Don't worry it might seem intimidating but it is not.\n\n# Step 2: Install the project \n\n## Using composer\n\nInstalling the project using composer is hands down the easiest way to get started. This method will download the project from GitHub\nand automatically install its dependencies for you. Presuming you installed composer (step 1) execute the following commands on the command-line.\n\n```bash\n$ composer create-project johnnymast/mysql_websocket_chat chat\n$ cd chat\n```\n\n\u003cem\u003eIn the above example I am using a mac so my prompt will display different then you if you are on windows.\u003c/em\u003e\n\n## Downloaded from phpclasses.org\n\nIf you download this package in a zip file from [phpclasses.org](http://www.phpclasses.org/package/9947-PHP-Websocket-starter-project.html) you will have to extract the zip package to a location of your liking. Then \nchange directory into that directory and execute the following command on your prompt.\n\n```bash\n$ composer install\n```\n\n\u003cem\u003eIn the above example I am using a mac so my prompt will display different then you if you are on windows.\u003c/em\u003e\n\n\n# Step 3: Configure the server\n\n## Websocket configuration\n\nThis project can be split into two different components. The WebSocket server is the \u003ccode\u003eserver.php\u003c/code\u003e in the root directory. The second part\nis the frontend part located in \u003ccode\u003epublic/index.php\u003c/code\u003e. For the WebSocket server, there are two configuration options that you can configure in \u003ccode\u003eincludes/config.php\u003c/code\u003e.\n\n#### WEBSOCKET_SERVER_IP\n\nThis flag allows you to configure the WebSocket server's IP-address. By default the value \u003ccode\u003e127.0.0.1\u003c/code\u003e has been set.\n\n#### WEBSOCKET_SERVER_PORT  \n\nThis will configure what port the WebSocket server will listen on. The default value has been set to \u003ccode\u003e8080\u003c/code\u003e. You can change this\nvalue if it clashes with other services running on your machine.\n\n\n\n## Database configuration\n\nThis server can run either with or without a database. By default i have disabled the use of a database server (\u003ccode\u003eENABLE_DATABASE\u003c/code\u003e) but you can enable it by switching the \u003ccode\u003eENABLE_DATABASE\u003c/code\u003e to \u003ccode\u003etrue\u003c/code\u003e\nin the [includes/config.php](https://github.com/johnnymast/mysql_websocket_chat/blob/master/includes/config.php) file. \n\n| Flag | Description |\n| --- | --- |\n| DATABASE_HOST | The database username goes in here. By default this has been set to \u003ccode\u003eroot\u003c/code\u003e. |\n| DATABASE_PORT | The database port goes in here. By default this has been set to \u003ccode\u003e3306\u003c/code\u003e. |\n| DATABASE_USERNAME | The database username goes in here. By default this has been set to \u003ccode\u003eroot\u003c/code\u003e.|\n| DATABASE_PASSWORD | Enter the password to access the database there. By default this has been set to \u003ccode\u003eroot\u003c/code\u003e.|\n| DATABASE_DB | Enter the name of the database here. By default this has been set to \u003ccode\u003esocket_chat\u003c/code\u003e.|\n| ENABLE_DATABASE | This flag will turn using the database on or off by setting its value to \u003ccode\u003etrue\u003c/code\u003e or \u003ccode\u003efalse\u003c/code\u003e.|\n\n\n***Please note*** if you enable the database make sure you update the credentials as well (see table above). Also, if you enable the database make sure you have imported [database.sql](https://github.com/johnnymast/mysql_websocket_chat/blob/master/database.sql) into your database.\n\n\n# Step 4: Fire up the WebSocket server\n\nChange direction into the chat directory and fire up the server.\n\n```bash\n$ cd chat\n$ php ./server.php\n```\n\nWhen you see no output and the command seems to hang that's when you know its running.\n\n\n# Step 5: Point a web service to the public directory\n\nIn the chat directory, you will find index.php. This file will be the client for your chat application. Make sure you set any web service its document root to the \u003ccode\u003epublic/\u003c/code\u003e folder. Alternatively, if you don't have access to a webserver you can also try using PHP's\nbuild-in webserver.\n\n```bash\n$ cd public\n$ php -S 127.0.0.1:8000\n```\n\n\u003cemn\u003eThis will start an webserver on port 8000\u003c/em\u003e  \n\n# Step 6: Chat away!\n\nNow open up 2 chat tabs and point them to localhost (or maybe a virtual host you configured) and chat away with your self.\n\n\n## Functionality\n\n#### Private chats\n\nIf you want to test private chats you can single click any user in the user list on the right of the screen. Then type your message\nin the message bar, this will send a private message only to that user.\n\n\n## Changes\n\nIf you wish to know what has changed in this version of Mysql WebSocket Chat you can always checkout the changelog [here](https://github.com/johnnymast/mysql_websocket_chat/blob/master/CHANELOG.md).\n\n\n## Author\n\nThis package is created and maintained by [Johnny Mast](mailto:mastjohnny@gmail.com). For feature requests or suggestions you could consider sending me an e-mail.\n\n## Enjoy\n\nOh and if you've come down this far, you might as well [follow me](https://twitter.com/mastjohnny) on twitter.\n \n\n## License\n\nMIT License\n\nCopyright (c) 2021 Johnny Mast\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n  ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnnymast%2Fmysql_websocket_chat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnnymast%2Fmysql_websocket_chat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnnymast%2Fmysql_websocket_chat/lists"}