Code Monkey home page Code Monkey logo

php-websocket's Introduction

Wrench

Simple WebSocket Client/Server for PHP

Formerly known as php-websocket

A simple websocket server and client package for PHP 5.3/5.4, using streams. Protocol support is based around RFC 6455, targeting the latest stable versions of Chrome and Firefox. (Suggest other clients here)

Backward compatibility

Public API

The new vendor namespace is Wrench. This namespace begins in the /lib directory, rather than server/lib.

Apart from the new namespace, the public API of this new major version is fairly compatible with that of php-websocket 1.0.0.

Protected API

The protected API has changed, a lot. Many method have been broken up into simple protected methods. This makes the Server class much easier to extend. In fact, almost all of the classes involved in your typical daemon can now be replaced or extended, including the socket handling and protocol handling.

What happened to the client dir?

The client-side libraries are no longer supported: some libraries are included but are packaged only as examples. You're free to use whatever client-side libraries you'd like with the server. If you're still using them, see the 1.0 branch.

Installation

The library is PSR-0 compatible, with a vendor name of Wrench. An SplClassLoader is bundled for convenience.

Usage

This creates a server on 127.0.0.1:8000 with one Application that listens for WebSocket requests to ws://localhost:8000/echo and ws://localhost:8000/chat:

$server = new \Wrench\BasicServer('ws://localhost:8000', array(
    'allowed_origins' => array(
        'mysite.com',
        'mysite.dev.localdomain'
    )
));
$server->registerApplication('echo', new \Wrench\Examples\EchoApplication());
$server->registerApplication('chat', new \My\ChatApplication());
$server->run();

Authors

The original maintainer and author was @nicokaiser. Plentiful improvements were contributed by @lemmingzshadow and @mazhack. Parts of the Socket class were written by Moritz Wutz. The server is licensed under the WTFPL, a free software compatible license.

Bugs/Todos/Hints

  • Add tests around fragmented payloads (split into many frames).
  • To report issues, see the issue tracker.

Examples

  • See server.php in the examples directory and Wrench\Application\EchoApplication
  • Jitt.li, a Twitter API sample project.
  • For Symfony2, VarspoolWebsocketBundle extends this library for use with the Service Container.

php-websocket's People

Contributors

dominics avatar nekudo avatar nicokaiser avatar mazhack avatar mgiustiniani avatar vincentdieltiens avatar mfairchild365 avatar

Watchers

James Cloos avatar Matthew M. Kaufman 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.