Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

deminy/xmpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Summary

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.

About

XMPP library for PHP, including implementations of XEP-0045 (Multi-User Chat).

Resources

License

Stars

Watchers

Forks

Languages