Git Product home page Git Product logo

xmpp's Introduction

fabiang/xmpp

Library for XMPP protocol connections (Jabber) for PHP.

License Latest Stable Version Total Downloads Dependency Status Build Status Coverage Status Scrutinizer Quality Score SensioLabsInsight

SYSTEM REQUIREMENTS

  • PHP minimum 5.6 or minimum 7.0
  • psr/log
  • (optional) psr/log-implementation - like monolog/monolog for logging

INSTALLATION

New to Composer? Read the introduction. Add the following to your composer file:

composer require fabiang/xmpp

DOCUMENTATION

This library uses an object to hold options:

use Fabiang\Xmpp\Options;
$options = new Options($address);
$options->setUsername($username)
    ->setPassword($password);

The server address must be in the format tcp://myjabber.com:5222.
If the server supports TLS the connection will automatically be encrypted.

You can also pass a PSR-2-compatible object to the options object:

$options->setLogger($logger)

The client manages the connection to the Jabber server and requires the options object:

use Fabiang\Xmpp\Client;
$client = new Client($options);
// optional connect manually
$client->connect();

For sending data you just need to pass a object that implements Fabiang\Xmpp\Protocol\ProtocolImplementationInterface:

use Fabiang\Xmpp\Protocol\Roster;
use Fabiang\Xmpp\Protocol\Presence;
use Fabiang\Xmpp\Protocol\Message;

// fetch roster list; users and their groups
$client->send(new Roster);
// set status to online
$client->send(new Presence);

// send a message to another user
$message = new Message;
$message->setMessage('test')
    ->setTo('[email protected]')
$client->send($message);

// join a channel
$channel = new Presence;
$channel->setTo('[email protected]')
    ->setPassword('channelpassword')
    ->setNickName('mynick');
$client->send($channel);

// send a message to the above channel
$message = new Message;
$message->setMessage('test')
    ->setTo('[email protected]')
    ->setType(Message::TYPE_GROUPCHAT);
$client->send($message);

After all you should disconnect:

$client->disconnect();

DEVELOPING

If you like this library and you want to contribute, make sure the unit-tests and integration tests are running. Composer will help you to install the right version of PHPUnit and Behat.

composer install

After that:

./vendor/bin/phpunit
./vendor/bin/behat

New features should always tested with Behat.

LICENSE

BSD-2-Clause. See the LICENSE.

TODO

  • Better integration of channels
  • Factory method for server addresses
  • improve documentation

xmpp's People

Contributors

fabiang avatar iivannov avatar n10ty avatar alexalouit avatar ghitu avatar frederikbosch avatar pirxthepilot avatar marclaporte avatar antonkomarev avatar

Watchers

James Cloos avatar Chenxiao Lu 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.