Download the PHP package nylo/smalljson without Composer

On this page you can find all versions of the php package nylo/smalljson. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package smalljson

SmallJson for Laravel

Shrink your API's JSON responses with a compact, reversible structural encoding — plus optional deflate — and serve them from a familiar one-liner:

Clients that advertise support get the small payload; everyone else transparently gets plain JSON. The smalljson Flutter package decodes it with a drop-in Dio interceptor, so your app code never knows the encoding happened.

How it works

SmallJson pulls every object key into a single key table and collapses uniform collections into row tuples:

For large payloads it can additionally deflate the result (mode z).

This is compression, not encryption. The payload is obfuscated to casual eyes, but anyone with the (open) spec can decode it — confidentiality comes from TLS.

Measured on realistic Laravel API payloads (composer bench):

All sizes in KB; % saved vs plain JSON.

Payload plain JSON smalljson p smalljson z plain + gzip p + gzip
users index, 100 rows + meta 37.5 KB 24.7 KB (−34.0%) 5.2 KB (−86.0%) 4.0 KB (−89.3%) 3.9 KB (−89.5%)
users index, 15 rows 5.5 KB 3.8 KB (−31.4%) 1.2 KB (−78.7%) 0.9 KB (−83.8%) 0.9 KB (−83.8%)
single user + 10 posts 1.7 KB 1.4 KB (−21.6%) 0.7 KB (−62.0%) 0.5 KB (−73.3%) 0.5 KB (−71.0%)
Full benchmark output

Read that table honestly: if your web server already gzips JSON responses, SmallJson's byte savings are modest. It shines when HTTP compression isn't in play — chunked/streamed responses, misconfigured proxies, shared hosting, internal service calls — and mode z brings its own compression with it. When the encoded form wouldn't be smaller, SmallJson automatically sends plain JSON instead, so it never costs you bytes.

Requirements

Installation

The service provider and SmallJson facade are auto-discovered. Optionally publish the config:

Usage

The macro

Works exactly like response()->json() — same arguments, same serialisation semantics:

The middleware (zero controller changes)

Prefer this if you want existing endpoints — resource responses, paginators, even JSON validation errors — encoded without touching any controller:

The middleware only rewrites JsonResponses, skips HEAD requests, and leaves anything that isn't plain JSON (JSONP, binary, streams) untouched.

Returning a resource from a route wraps it in data before the middleware runs, so the wrapper is preserved. The macro mirrors response()->json() instead, which — like Laravel itself — does not apply resource wrapping.

Manual encode/decode

Useful for websockets, queued payloads, and cache entries. The codec itself (SmallJson\Codec\Codec) is framework-free if you need it outside Laravel.

Negotiation

By default nothing changes for clients that don't opt in:

  1. A capable client sends X-Small-Json: pz (the modes it accepts). The Flutter interceptor does this automatically.
  2. The server responds with Content-Type: application/vnd.smalljson+json and the encoded body — or plain JSON when encoding wouldn't help. Vary: X-Small-Json is set either way so shared caches keep the variants apart.

Set 'negotiate' => false to encode for every client — only do this when you control all consumers. Browsers calling your API with the header from JavaScript will need X-Small-Json whitelisted in your CORS allowed_headers.

Configuration

Key Default Meaning
enabled true (SMALLJSON_ENABLED) Master switch; off = plain JSON everywhere
modes 'pz' (SMALLJSON_MODES) Encodings the server may produce
negotiate true (SMALLJSON_NEGOTIATE) Require the request header before encoding
request_header 'X-Small-Json' Capability header name
content_type application/vnd.smalljson+json Marker content type on encoded responses
min_bytes 0 (SMALLJSON_MIN_BYTES) Skip encoding below this plain-JSON size
only_when_smaller true Fall back to plain JSON unless encoding shrinks it
deflate.min_bytes 1024 Only try mode z at or above this envelope size
deflate.level 6 DEFLATE level (1–9)
stats_header false (SMALLJSON_STATS) Add X-Small-Json-Stats with the savings

Tip: while evaluating, set SMALLJSON_STATS=true and watch the header: X-Small-Json-Stats: mode=z; plain=37462; sent=5236; saved=86.0%.

Clients

Testing

The suite includes shared wire-format vectors (tests/Fixtures/vectors.json) verified byte-for-byte against the Dart implementation — both directions.

License

MIT © Anthony Gordon


All versions of smalljson with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
ext-zlib Version *
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nylo/smalljson contains the following files

Loading the files please wait ...