Giter Site home page Giter Site logo

flxxyz / php-chat-websocket Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 4.0 550 KB

💬 简单在线聊天室。

License: MIT License

PHP 44.50% CSS 42.79% JavaScript 10.21% Shell 0.10% Hack 2.41%
chat-room swoole swoole-extension identicon websockets php-chat-websocket

php-chat-websocket's Introduction

php-chat-websocket

这是一个基础聊天室,使用session区分各个用户,使用identicon来做随机头像

ps:不清楚identicon的可以看看identicon wiki

Init

依次执行下面命令

git clone https://github.com/flxxyz/php-chat-websocket.git && cd php-chat-websocket
composer update --no-dev

Usage

  1. 修改 config/config.php 4行

    'url' => 'http://domain/',  //保留最后的斜杠
  2. 修改app/view/js.view.php 155行为websocket链接🔗

    var socket = new ReconnectingWebSocket('ws://你的域名:9501', null, {debug: false, reconnectInterval: 2000, timeoutInterval: 3000});
  3. 自定义ip端口号

    Chat::run('自定义ip', '自定义端口号');
  4. 开启websocket服务器

    php run.php  // 同步检查控制台输出信息

    如需要后台挂起服务看这里↓

    chmod +x start_chat.sh
    ./start_chat.sh
  5. 伪静态设置 nginx和apache需要设置伪静态规则,在这里只提供nginx的规则,apache不熟

    location / {
        try_files $uri $uri/ /index.php$is_args$query_string;
    }
    

Route

路径 说明
/ 首页界面
/logout 注销当前登陆用户
/room 房间界面

php-chat-websocket's People

Contributors

flxxyz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.