PHPackages                             kadet/nucleus - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. kadet/nucleus

ActiveLibrary[Queues &amp; Workers](/categories/queues)

kadet/nucleus
=============

Asynchronous XMPP Library for PHP

v0.2.0(9y ago)9343MITPHPPHP &gt;=7.0

Since Jul 26Pushed 9y ago3 watchersCompare

[ Source](https://github.com/kadet1090/nucleus)[ Packagist](https://packagist.org/packages/kadet/nucleus)[ RSS](/packages/kadet-nucleus/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (2)Dependencies (11)Versions (4)Used By (0)

[![Nucleus Logo](https://camo.githubusercontent.com/635b43410b99a56ff596c3b87e3e8adea700c42cd77dd9b021f2d320fe93f183/68747470733a2f2f646c2e64726f70626f7875736572636f6e74656e742e636f6d2f752f36303032303130322f5368617265582f323031362d30372f6e75636c6575735f4c6f676f2532302532422532304c6f676f7479702532302d253230436f6c6f722e706e67)](https://camo.githubusercontent.com/635b43410b99a56ff596c3b87e3e8adea700c42cd77dd9b021f2d320fe93f183/68747470733a2f2f646c2e64726f70626f7875736572636f6e74656e742e636f6d2f752f36303032303130322f5368617265582f323031362d30372f6e75636c6575735f4c6f676f2532302532422532304c6f676f7479702532302d253230436f6c6f722e706e67)

\[WiP\] Nucleus - XMPP Library for PHP
======================================

[](#wip-nucleus---xmpp-library-for-php)

[![Packagist](https://camo.githubusercontent.com/612716cac1d794ea23cca00b946b916ffea1eca4b2e61e918599bd834bf4bef5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b616465742f6e75636c6575732e7376673f6d61784167653d323539323030303f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kadet/nucleus)[![Milestone](https://camo.githubusercontent.com/706cd5739234bc9c67e149e8963390f03b1b91382e3480843a4fe5077b5b1236/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d696c6573746f6e652d322d79656c6c6f772e737667)](https://camo.githubusercontent.com/706cd5739234bc9c67e149e8963390f03b1b91382e3480843a4fe5077b5b1236/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d696c6573746f6e652d322d79656c6c6f772e737667)[![Travis](https://camo.githubusercontent.com/4094acc6fad1932c19fc0a7e4a0c7623270faae86a8b4ef8ad1cc29caae4abac/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6b61646574313039302f6e75636c6575732e7376673f6d61784167653d323539323030303f7374796c653d666c61742d737175617265)](https://travis-ci.org/kadet1090/nucleus)[![Scrutinizer](https://camo.githubusercontent.com/632780867719ccd95a58fae87e17b84dc98a4f086fb2b0a6871f160910b0e096/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6b61646574313039302f6e75636c6575732e7376673f6d61784167653d323539323030303f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/kadet1090/nucleus/?branch=master)![Code Climate](https://camo.githubusercontent.com/bdf0729d799da28c1aca5f960ab60829732fa8689600a1b664fa33eb0cc7a8f4/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6769746875622f6b61646574313039302f6e75636c6575732e7376673f6d61784167653d32353932303030)[![Scrutinizer Coverage](https://camo.githubusercontent.com/0f832224e48abb754709868d7da964a5576d3fa6def6247c9a00dc82d9a97651/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6b61646574313039302f6e75636c6575732e7376673f6d61784167653d323539323030303f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/0f832224e48abb754709868d7da964a5576d3fa6def6247c9a00dc82d9a97651/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6b61646574313039302f6e75636c6575732e7376673f6d61784167653d323539323030303f7374796c653d666c61742d737175617265)

Asynchronous XMPP library for PHP based on [React PHP](https://github.com/reactphp). Library is still work in progress, so I don't recommend using it. It obsoletes my old [`kadet/xmpp`](https://github.com/kadet1090/xmpp) package.

Already available
-----------------

[](#already-available)

### Modular Client class

[](#modular-client-class)

By design client class (`\Kadet\Xmpp\XmppClient`) acts like stream - for sending and receiving packets over network, event emitter to inform about events, and dependency container (what a wonderful violation of SRP) for managing modules. It allows to move almost all logic outside of that class into proper and exchangeable components.

Basic client instance can be set up quite easily:

```
$loop   = React\EventLoop\Factory::create();
$client = new \Kadet\Xmpp\XmppClient(new \Kadet\Xmpp\Jid('local@domain.tld/resource'), [
    'loop'     => $loop,
    'password' => 'epicpasspeoem',
]);

// Event declatation ...

$client->connect();
$loop->run();
```

Options passed to second argument, are equivalent to C#'s property instantiation, so above example is same as calling:

```
$client = new \Kadet\Xmpp\XmppClient(new \Kadet\Xmpp\Jid('local@domain.tld/resource'));
$client->loop = $loop;
$client->password = 'epicpasspoem';
```

With exception for `modules` and `default-modules` which are used for initial module setup. You can disable default modules by setting `default-modules` to false, but it's highly not recommended for non-test purposes.

Available events are:

```
element(Kadet\Xmpp\Xml\XmlElement $element) // element received
features(Kadet\Xmpp\StreamFeatures $features) // features received

send.element(Kadet\Xmpp\Xml\XmlElement $element) // element sent
send.text(string $data) // some text (non valid XmlElement) sent

stream.open(Kadet\Xmpp\Xml\XmlElement $stream) // Stream started
stream.close() // Stream closed

stream.error(Kadet\Xmpp\Stream\Error $error) // Stream errored

connect(StreamDuplexInterface $stream) // called when connection is ready
exception(Exception $exception) // called when otherwise unhandled exception happens
```

also, all default events from [`react/stream`](https://github.com/reactphp/stream) are applicable.

#### TLS Handling

[](#tls-handling)

Most of XMPP servers require TLS connection, by default React streams don't support encryption. Library will handle encryption if underlying stream implements `\Kadet\Xmpp\Network\SecureStream` interface (provided stream classes like `\Kadet\Xmpp\Network\TcpStream` implements it by default).

### (Better)Event API

[](#betterevent-api)

Nucleus uses extended version of [`evenement/evenement`](https://packagist.org/packages/evenement/evenement) to provide convenient `EventEmitter` API. So you can now filter events by predicates and event queue is prioritized.

```
$emitter->on($event, $callback, $predicate = null, $priority = 0);
```

Predicate, as well as callback is called with arguments passed to event. There are few default predicates that you can use, they can be found in [`Utils/Filter.php`](Utils/Filter.php).

```
// Will fire event only if element belongs into self::TLS_NAMESPACE.
$stream->on('element', $callable, with\xmlns(self::TLS_NAMESPACE));
```

Also you can prioritize events

```
$stream->on('element', $second, null, 0);
$stream->on('element', $first, null, 1); // will fire first
```

Sender argument is not provided by default, if needed you have to partially apply function, there is also shortcut in every event emitting class.

```
$stream->on('element', $stream->reference($callable)); // Will fire $callable($stream, ...$arguments);
```

Event queue can be stopped by returning `false` by event.

Things to do
------------

[](#things-to-do)

See roadmap on [Trello](https://trello.com/b/WHQ6d3hw/xmpp), I'll keep it updated. Project is created in milestone system, it means that after completing each milestone API should be stable - but it's not guaranteed at the moment.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~26 days

Total

2

Last Release

3600d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e7113b0385cd7e51daf6144d435554cfca689e1d82291e2ba33abe31dbe881aa?d=identicon)[Kadet](/maintainers/Kadet)

---

Top Contributors

[![kadet1090](https://avatars.githubusercontent.com/u/747404?v=4)](https://github.com/kadet1090 "kadet1090 (121 commits)")

---

Tags

jabberphpphp-7xmpp-libraryasyncreactimxmppjabber

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kadet-nucleus/health.svg)

```
[![Health](https://phpackages.com/badges/kadet-nucleus/health.svg)](https://phpackages.com/packages/kadet-nucleus)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[react/socket

Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP

1.3k129.1M441](/packages/react-socket)[clue/docker-react

Async, event-driven access to the Docker Engine API, built on top of ReactPHP.

112160.9k1](/packages/clue-docker-react)[clue/reactphp-eventsource

Instant real-time updates. Lightweight EventSource client receiving live messages via HTML5 Server-Sent Events (SSE). Fast stream processing built on top of ReactPHP's event-driven architecture.

5819.5k3](/packages/clue-reactphp-eventsource)[recoil/react

Integrate Recoil with ReactPHP.

32286.7k12](/packages/recoil-react)[badfarm/zanzara

Asynchronous PHP Telegram Bot Framework

2022.5k](/packages/badfarm-zanzara)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
