PHPackages                             kionik/caesar - 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. kionik/caesar

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

kionik/caesar
=============

Asynchronous string, file and xml readers based on ReactPHP

1.1.2(6y ago)25[2 issues](https://github.com/kionik/caesar/issues)MITPHPPHP ^7.1CI failing

Since Jul 15Pushed 6y ago1 watchersCompare

[ Source](https://github.com/kionik/caesar)[ Packagist](https://packagist.org/packages/kionik/caesar)[ RSS](/packages/kionik-caesar/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (4)Versions (11)Used By (0)

Caesar
======

[](#caesar)

Caesar is a library based on ReactPHP technology that provides to read strings and files in an asynchronous way and find matches in them by patterns.

Basic usage
===========

[](#basic-usage)

```
$loop = \React\EventLoop\Factory::create();
$reader = new \Kionik\Caesar\Reader($loop);
$reader->onFind('/foo/', function (string $foo) {
    echo $foo; // return 'foo'
});
$reader->onEnd(function() {
    echo PHP_EOL . 'finish reading';
});
$reader->read('foo bar');

// some code...

// This can be replaced by $loop->run();
$reader->run();
```

`Reader` working only with a strings, parse it and return result of parsing if found something.

FileReader
==========

[](#filereader)

`FileReader` working only with a resources. Inside of read method use `React\Stream\ReadableResourceStream` of ReactPHP library that provides to read file in asynchronous stream way.

```
$fileName = 'foo.txt';
file_put_contents($fileName, 'foo bar');
$loop = \React\EventLoop\Factory::create();
$reader = new \Kionik\Caesar\FileReader($loop);
$reader->onFind('/foo/', function (string $foo) {
    echo $foo; // return 'foo'
});
$reader->read(fopen($fileName, 'rb'));

// some code...

$reader->run();
unlink($fileName);
```

You can change size of one chunk by using second parameter `$chunkSize` of `read` method

```
$chunkSize = 1;
$reader->read(fopen('foo.txt', 'rb'), $chunkSize);
```

If you change chunk size then don't forget to change `Parser::$storeChunksCount` by using

```
$reader->setStoreChunksCount(10);
```

This parameter is responsible for the maximum number of chunks that will stored in `FileReader` memory, if `FileReader` wouldn't find something in previous chunks.

XmlStringReader
===============

[](#xmlstringreader)

```
$loop = \React\EventLoop\Factory::create();
$reader = new \Kionik\Caesar\XmlStringReader($loop);
$reader->onFind('foo', function (string $foo) {
    echo $foo; // return 'bar'
});
$reader->read('barfoo');

// some code...

$reader->run();
```

XmlFileReader
=============

[](#xmlfilereader)

```
$fileName = 'foo.xml';
$xmlWriter = new \XMLWriter();
$xmlWriter->openMemory();
$xmlWriter->startDocument('1.0', 'UTF-8');
$xmlWriter->writeElement('foo', 'bar');
$xmlWriter->writeElement('bar', 'foo');
file_put_contents($fileName, $xmlWriter->flush(), FILE_APPEND);

$loop = \React\EventLoop\Factory::create();
$reader = new \Kionik\Caesar\XmlFileReader($loop);
$reader->onFind('foo', function (string $foo) {
    echo $foo; // return 'bar'
});
$reader->read(fopen($fileName, 'rb'));

// some code...

$reader->run();
unlink($fileName);
```

> *Note:* XML readers does not work correctly in cases where tags are repeated inside themselves like:
> `bar`

Handlers
========

[](#handlers)

All readers provides to use handlers for handling data before it returns to `$listener`.

```
$loop = \React\EventLoop\Factory::create();
$reader = new \Kionik\Caesar\XmlStringReader($loop);

$reader
    ->onFind('tag', function (SimpleXMLElement $tag) {
        echo $tag->attributes()->getName(); // return 'foo'
    })
    ->handler(new \Kionik\Caesar\Handlers\Xml\SimpleXMLElementHandler());

$reader->read('');

// some code...

$reader->run();
```

Licensing
=========

[](#licensing)

All of the code in this library is licensed under the MIT license as included in the LICENSE file.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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 ~2 days

Total

10

Last Release

2476d ago

Major Versions

0.5.0 → 1.0.02019-08-03

### Community

Maintainers

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

---

Top Contributors

[![toopleks](https://avatars.githubusercontent.com/u/29703707?v=4)](https://github.com/toopleks "toopleks (2 commits)")

---

Tags

asyncasynchronousxmlstringparserreactphpfilereaderfast

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kionik-caesar/health.svg)

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

###  Alternatives

[react/socket

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

1.3k116.9M402](/packages/react-socket)[revolt/event-loop

Rock-solid event loop for concurrent PHP applications.

91943.6M138](/packages/revolt-event-loop)[amphp/parallel

Parallel processing component for Amp.

84746.2M74](/packages/amphp-parallel)[amphp/sync

Non-blocking synchronization primitives for PHP based on Amp and Revolt.

18852.8M39](/packages/amphp-sync)[react/promise-stream

The missing link between Promise-land and Stream-land for ReactPHP

11512.9M45](/packages/react-promise-stream)[amphp/parser

A generator parser to make streaming parsers simple.

14952.8M16](/packages/amphp-parser)

PHPackages © 2026

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