Looking to hire Laravel developers? Try LaraJobs

laravel maintained by scon

Description
SCON — Schema-Compact Object Notation: Laravel integration with response macros, request parsing, and Facade
Author
Last update
2026/03/17 00:32 (dev-init)
License
Downloads
0

Comments
comments powered by Disqus

scon/laravel

SCON — Schema-Compact Object Notation for Laravel

Laravel integration for SCON. 59-66% payload reduction, 64% fewer LLM tokens, zero config.

Packagist License: MIT

Install

composer require scon/laravel

Auto-discovery registers the service provider and facade. No config file needed.

Usage

Facade

use Scon\Laravel\Facades\SCON;

# Encode
$scon = SCON::encode(['name' => 'scon', 'version' => 1]);

# Decode
$data = SCON::decode($sconString);

# Minify / Expand
$mini = SCON::minify($sconString);
$expanded = SCON::expand($mini);

# Structural dedup (59-66% reduction on repetitive data)
$scon = SCON::encode($data, ['autoExtract' => true]);

# Check if Rust extension is loaded
$fast = SCON::isAccelerated(); // true if php-scon ext is available

Response macro

# Return SCON response with Content-Type: text/scon
return response()->scon($data);
return response()->scon($data, 201);
return response()->scon($data, 200, ['X-Custom' => 'header']);

Request macros

# Parse SCON request body
$data = $request->scon();

# Check if request is SCON
if ($request->isScon()) {
    $data = $request->scon();
}

API example

Route::post('/api/config', function (Request $request) {
    if ($request->isScon()) {
        $config = $request->scon();
    } else {
        $config = $request->json()->all();
    }

    return response()->scon([
        'status' => 'saved',
        'entries' => count($config),
    ]);
});

Native acceleration

scon/laravel uses scon/scon which auto-detects the Rust native extension when available. No code changes needed — SCON::encode() and SCON::decode() transparently use the tape decoder for near-parity with json_decode.

# Check acceleration status
php -r "require 'vendor/autoload.php'; echo Scon\Scon::isAccelerated() ? 'native' : 'pure PHP';"

Performance

Payload reduction on OpenAPI 3.1 spec (71 endpoints):

Format Bytes Ratio
JSON 90,886 1.00x
SCON 26,347 0.29x
SCON (minified) 20,211 0.22x

LLM token efficiency (cl100k_base): 64% fewer tokens — less context window waste for RAG pipelines, tool-use agents, and structured prompts.

Full methodology: DOI 10.5281/zenodo.14733092 Benchmarks, optimization log (21 phases), and industrial protocol fixtures: github.com/QuijoteShin/scon

Also available

License

MIT