~/docs
Resonate
Resonate
0.x 0.3.0, current
php-resp3
Toggle sidebar
php-resp3
webpatser/php-resp3 0.3.0

php-resp3 0.x

Introduction

php-resp3 is a PHP extension that parses RESP3 wire bytes into PHP values in C.

php-resp3 is a small PECL extension that turns RESP3 wire bytes into PHP values. That is the whole job. It has no sockets, no commands and no connection management. You feed it bytes and pull out parsed messages.

Warning: v0.x: the API may change. Breaking changes can land in any 0.x minor release and are called out in the changelog.

Why it exists

Pure-PHP RESP parsers are generator-based and dominate wall clock when one round-trip returns many small values. A Cache::many($keys) call with a thousand keys spends most of its PHP time inside the parser's state machine, not in the application. This extension parses the same wire bytes in C and exposes the same value tree.

The output structure is verified identical to the pure-PHP parsers it replaces (bench/validate_01_structure_parity.php in the repository).

Where it helps

Use the C parser when parsing owns a meaningful share of your wall clock:

  • Cache-heavy reads (MGET fan-out, tag invalidation, large hash reads) where one round-trip returns many small bulk strings.
  • Workloads where the application work per parsed value is light.
  • FalkorDB and RedisGraph queries that return deeply nested arrays.

Skip it when round-trip latency or per-job work dominates, for example queue workers with one fetch, one ACK and one DEL per job. There the parser share of total wall clock is small enough that a large parser speedup lands as a single-digit percentage end to end. See Benchmarks for the measurements.

laravel-resp3-cache builds a Laravel Redis client and cache store on this extension.

What is in the box

  • Resp3\Parser, an incremental parser: feed(), hasNext(), next(), plus push queue, attribute and reset methods.
  • Resp3\RedisException, Resp3\VerbatimString and Resp3\PushMessage wrapper classes.
  • resp3_version(), which returns the extension version.
  • Adapter classes in src/Adapter/ that plug the parser into amphp/redis. fledge-fiber uses the extension automatically when it is loaded.

Limits

  • Streamed types ($?, *?, ~?, %?) are rejected. Redis does not ship them and no server command emits them.
  • Inline commands (PING\r\n style input) are rejected. The parser sits on the server-to-client side.

Next steps