PHPackages                             vinkius-labs/synapse-toon - 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. [API Development](/categories/api)
4. /
5. vinkius-labs/synapse-toon

ActiveLibrary[API Development](/categories/api)

vinkius-labs/synapse-toon
=========================

Synapse TOON - high-performance API payload optimization and streaming toolkit for Laravel 11/12

v1.0.0(2mo ago)10Apache-2.0PHPPHP ^8.2 || ^8.3CI passing

Since Nov 12Pushed 2mo agoCompare

[ Source](https://github.com/vinkius-labs/synapse-toon)[ Packagist](https://packagist.org/packages/vinkius-labs/synapse-toon)[ RSS](/packages/vinkius-labs-synapse-toon/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (3)Used By (0)

 **Synapse TOON**
 *High-performance API payload optimization engine for Laravel*

 [![Tests](https://github.com/vinkius-labs/synapse-toon/actions/workflows/tests.yml/badge.svg)](https://github.com/vinkius-labs/synapse-toon/actions/workflows/tests.yml) [![License](https://camo.githubusercontent.com/5b60841bea9e11d9d0b0950d690c9bc554e06385634056a7d5d62a15d1a4eabe/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4170616368655f322e302d626c75652e737667)](https://opensource.org/licenses/Apache-2.0) [![Latest Version](https://camo.githubusercontent.com/7f04d435d7af30759bf8432b935d7e6233836ade25c38949a7db1c00ad0beb68/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f76696e6b6975732d6c6162732f73796e617073652d746f6f6e2e737667)](https://packagist.org/packages/vinkius-labs/synapse-toon) [![Total Downloads](https://camo.githubusercontent.com/7c657aeb3759c65d4960d8b6b00d8e59aea685fdd46e75c087ea3bed950ce0b2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f76696e6b6975732d6c6162732f73796e617073652d746f6f6e2e737667)](https://packagist.org/packages/vinkius-labs/synapse-toon) [![PHP 8.2+](https://camo.githubusercontent.com/9051b6544f57608ca691a918b38ad8c567657e0ecb6d4e960be274f287d171d8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d3838393242462e737667)](https://php.net) [![Laravel](https://camo.githubusercontent.com/55896a05c3ec030eaca4695c90eb92a015243408c80c7675f6ffeb3b910d50c0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31312e7825323025374325323031322e782d4646324432302e737667)](https://laravel.com)

---

Synapse TOON transforms verbose JSON API responses into ultra-dense representations, reducing token consumption by **25–45%** while preserving full semantic fidelity. Ship faster APIs and pay dramatically less for LLM inference.

Every runtime surface ships with an explicit `SynapseToon` prefix, making package ownership obvious in your codebase and eliminating class-name collisions.

Highlights
----------

[](#highlights)

- **Cost Savings First** — Reduce LLM API bills by 25–45% through entropy-aware encoding, adaptive compression, and smart routing.
- **Performance Native** — HTTP/3 detection, Brotli/Gzip negotiation, and SSE streaming deliver sub-100 ms response times.
- **Observable by Default** — Log, Prometheus, and Datadog drivers expose savings metrics and ROI in real time.
- **Production Ready** — Queue-aware batch jobs, edge caching, and complexity-aware routing keep high-traffic APIs responsive.
- **Framework Native** — Middleware aliases, response macros, and Octane preloading for zero-friction Laravel integration.
- **Zero Lock-in** — Bring your own vector stores, LLM clients, and cache drivers via lightweight contracts.

Requirements
------------

[](#requirements)

DependencyVersionPHP8.2+Laravel11.x | 12.xext-brotliOptional (recommended)ext-zlibOptionalInstallation
------------

[](#installation)

```
composer require vinkius-labs/synapse-toon
```

Publish the configuration file:

```
php artisan vendor:publish --tag=synapse-toon-config
```

Register middleware in `bootstrap/app.php`:

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->api(append: [
        \VinkiusLabs\SynapseToon\Http\Middleware\SynapseToonCompressionMiddleware::class,
        \VinkiusLabs\SynapseToon\Http\Middleware\SynapseToonHttp3Middleware::class,
    ]);
})
```

Quick Start
-----------

[](#quick-start)

### Encode a response

[](#encode-a-response)

```
use VinkiusLabs\SynapseToon\Facades\SynapseToon;

// Before: 1,247 tokens → After: 683 tokens (45% reduction)
$encoded = SynapseToon::encoder()->encode([
    'products' => Product::with('category', 'reviews')->get(),
    'meta' => ['page' => 1, 'per_page' => 50],
]);

return response()->synapseToon($encoded);
```

### Stream an LLM response

[](#stream-an-llm-response)

```
return response()->synapseToonStream($llmStream, function ($chunk) {
    return [
        'delta' => $chunk['choices'][0]['delta']['content'],
        'usage' => $chunk['usage'] ?? null,
    ];
});
```

### Route by complexity

[](#route-by-complexity)

```
$target = SynapseToon::router()->route($payload, [
    'complexity' => 0.4,
    'tokens' => 512,
]);
```

### Build RAG context

[](#build-rag-context)

```
$context = SynapseToon::rag()->buildContext(
    'How do I implement OAuth2 in Laravel?',
    ['user_id' => auth()->id()]
);
```

### Dispatch a batch job

[](#dispatch-a-batch-job)

```
use VinkiusLabs\SynapseToon\Jobs\SynapseToonProcessLLMBatchJob;

SynapseToonProcessLLMBatchJob::dispatch($prompts, [
    'queue'      => 'llm-batch',
    'connection' => 'openai',
    'batch_size' => 50,
]);
```

Architecture Overview
---------------------

[](#architecture-overview)

ComponentPurpose`SynapseToonEncoder` / `SynapseToonDecoder`Lossless TOON codec with dictionary support and entropy-aware heuristics`SynapseToonCompressor`Adaptive Brotli, Gzip, and Deflate selection based on `Accept-Encoding``SynapseToonSseStreamer`Server-Sent Events with zero-copy chunking and buffer flush guardrails`SynapseToonEdgeCache`Encode-once edge cache helper tuned for Redis and Octane workloads`SynapseToonMetrics`Driver-agnostic metrics (Log, Prometheus, Datadog, or custom drivers)`SynapseToonProcessLLMBatchJob`Queue-friendly batch encoder for up to 100 prompts per dispatch`SynapseToonLLMRouter`Complexity-aware model router with pluggable LLM client implementations`SynapseToonRagService`Vector-store abstraction with snippet thresholds and metadata braiding`SynapseToonGraphQLAdapter`Lighthouse / Rebing GraphQL pipeline with TOON encoding built in`SynapseToonPayloadAnalyzer`Token analytics and savings calculator for middleware and dashboardsReal-World Impact
-----------------

[](#real-world-impact)

ScenarioBeforeAfterSavingsE-commerce feed (500 items)47,200 tokens26,100 tokens**44.7%**Chat completion with context3,840 tokens2,310 tokens**39.8%**GraphQL nested query2,156 tokens1,405 tokens**34.8%**RAG context injection1,920 tokens1,152 tokens**40.0%**Batch job (50 prompts)12,500 tokens7,000 tokens**44.0%****Average token reduction: 40.7%**

Documentation
-------------

[](#documentation)

GuideDescription[Getting Started](docs/getting-started.md)Installation, first response, and quick tips[Configuration](docs/configuration.md)Full reference for every config option[Encoding &amp; Compression](docs/encoding-compression.md)TOON algorithm deep-dive and compression strategies[Streaming &amp; SSE](docs/streaming-sse.md)Server-Sent Events for real-time LLM responses[Metrics &amp; Analytics](docs/metrics-analytics.md)Prometheus, Datadog, and custom driver setup[RAG Integration](docs/rag-integration.md)Vector-store abstraction and context building[Batch Processing](docs/batch-processing.md)Queue-native batch encoding and fan-out[GraphQL Adapter](docs/graphql-adapter.md)Lighthouse / Rebing integration[Edge Cache](docs/edge-cache.md)Multi-tier caching strategies[HTTP/3 Optimization](docs/http3-optimization.md)HTTP/3 detection and header optimization[Cost Optimization](docs/cost-optimization.md)Maximize ROI with concrete strategies[Performance Tuning](docs/performance-tuning.md)Latency and throughput optimization[Technical Reference](docs/technical-reference.md)Container bindings, macros, and full APITesting
-------

[](#testing)

Run the test suite locally via Docker:

```
docker compose build
docker compose run --rm app bash -c "composer install --no-interaction && vendor/bin/phpunit"
```

Or, if you have PHP 8.2+ installed locally:

```
composer install
vendor/bin/phpunit
```

Compatibility
-------------

[](#compatibility)

ComponentSupportLaravel11.x, 12.xPHP8.2, 8.3OctaneSwoole, RoadRunner, FrankenPHPHTTP/3Full detection and optimizationBrotliOptional (`ext-brotli`)Contributing
------------

[](#contributing)

Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) before submitting a pull request.

Security
--------

[](#security)

If you discover a security vulnerability, please review our [Security Policy](SECURITY.md). **Do not open a public issue.**

Changelog
---------

[](#changelog)

All notable changes are documented in the [Changelog](CHANGELOG.md).

License
-------

[](#license)

Copyright 2026 Vinkius Labs

Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for the full text.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance83

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Total

2

Last Release

84d ago

Major Versions

0.0.1 → v1.0.02026-02-17

### Community

Maintainers

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

---

Top Contributors

[![renatomarinho](https://avatars.githubusercontent.com/u/26571?v=4)](https://github.com/renatomarinho "renatomarinho (13 commits)")

---

Tags

composer-packagelaravellaravel-packagelaravel12x-apillmllm-costtoonlaravelcompressionstreamingoptimizationllmapis

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/vinkius-labs-synapse-toon/health.svg)

```
[![Health](https://phpackages.com/badges/vinkius-labs-synapse-toon/health.svg)](https://phpackages.com/packages/vinkius-labs-synapse-toon)
```

###  Alternatives

[irazasyed/telegram-bot-sdk

The Unofficial Telegram Bot API PHP SDK

3.3k4.5M84](/packages/irazasyed-telegram-bot-sdk)[dcblogdev/laravel-microsoft-graph

A Laravel Microsoft Graph API (Office365) package

168285.5k1](/packages/dcblogdev-laravel-microsoft-graph)[vluzrmos/slack-api

Wrapper for Slack.com WEB API.

102589.1k3](/packages/vluzrmos-slack-api)[dcblogdev/laravel-xero

A Laravel Xero package

53129.1k1](/packages/dcblogdev-laravel-xero)[neuron-core/neuron-laravel

Official Neuron AI Laravel SDK.

10710.0k](/packages/neuron-core-neuron-laravel)[simplestats-io/laravel-client

Client for SimpleStats!

4515.5k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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