deminy/xmpp

This package is abandoned and no longer maintained. No replacement package was suggested.

A client library for talking to XMPP servers.

0.0.2 2014-12-16 22:43 UTC

This package is auto-updated.

Last update: 2020-03-13 01:39:11 UTC


README

Before creating this repository, I've evaluated following XMPP libraries for PHP:

Unfortunately, none of above ships with what I need. That's the reason I'm creating this repository based on Nikita's work.

Features

  • Following features were shipped already from Nikita's fork:
    • Connects to and authenticates (using DIGEST-MD5) against XMPP servers (tested against Openfire and jabberd2)
    • Supports SSL/TLS connections
    • Allows joining of MUC rooms
    • Sends messages to individuals and MUC rooms.
  • Following features are added by me, plus various refactoring, etc:
    • Connects to and authenticates using PLAIN.
    • XEP-0045 (Multi-User Chat) related implementations, including to create chatroom, destroy chatroom, grant member, revoke member and get member list.

Sample Code

use Xmpp\Xep\Xep0045 as xmpp;

$roomId = 'YourHouse';
$userId = 'Tom';

$options = array(
    'username'  => 'your_username',
    'password'  => 'your_password',
    'host'      => 'example.com',
    'ssl'       => false,
    'port'      => 5222,
    'resource'  => uniqid('', true),
    'mucServer' => 'conference.example.com', // optional
);
$xmpp = new xmpp($options, $logger);

$xmpp->createRoom($roomId);            // Create the room.
$xmpp->grantMember($roomId, $userId);  // Add a member to the room.
$xmpp->getMemberList($roomId);         // Get member list and there should be only one member.
$xmpp->revokeMember($roomId, $userId); // Remove the only member out from the room.
$xmpp->getMemberList($roomId);         // Get member list and there should be nobody in the room.
$xmpp->destroyRoom($roomId);           // Destroy the room.
$xmpp->disconnect();                   // Disconnect from the server. Important for heavy-loaded servers.

Known Limitations

  • Only part of XEP-0045 (Multi-User Chat) protocol extension have been implemented.
  • Although code was refactored/written following FIG PSR standards, it was developped and tested for certain project under certain environment only.

Credits

  • Nikita's fork.
  • Valuable suggestions, helps on performance improments and tests from colleague Jose (known to all as Tachu), Jakub and Jerry.

License

MIT license.