Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Php Compress Json

Php Compress Json Laravel Package

inkrot/php-compress-json

A lightweight PHP library that compresses and minifies JSON by stripping whitespace and redundant formatting, shrinking payloads for APIs, storage, and caching. Simple to install, framework-agnostic, and built to reduce JSON size without altering the underlying data.

Deep Wiki
Context7

inkrot/php-compress-json provides lossless JSON compression for PHP applications, helping reduce payload size for storage, caching, and network transfer. It is a lightweight utility designed to shrink JSON data while allowing the original structure to be reconstructed.

  • Lossless compression and decompression of JSON data
  • Reduces payload size for APIs, caches, and storage
  • Preserves data structure and values after round-trip
  • Simple PHP API for fast integration
  • Composer-installable with minimal setup
Frequently asked questions about Php Compress Json
What does inkrot/php-compress-json do and when is it worth using?
It is a PHP library that compresses JSON payloads losslessly, so you can shrink data before writing it to a database column, cache, queue, log store, or sending it over the wire, then restore the original JSON later. It is most useful for high-volume JSON-at-rest where storage cost or bandwidth is a real concern. It is not a replacement for HTTP compression such as gzip/brotli, Laravel's JSON casts, or database JSON querying. For low-volume payloads the savings rarely justify the extra moving parts.
Is inkrot/php-compress-json a Laravel package or a plain PHP library?
Based on the available information it appears to be a low-level PHP serialization/compression utility rather than a Laravel-native package with service providers, config files, or facades. That means you integrate it yourself, typically behind a small internal service or a custom Eloquent cast. Treat it as a contained adapter rather than a cross-cutting dependency. Confirm the actual API surface once you can inspect the source.
How do I install inkrot/php-compress-json with Composer?
Install it the usual way with composer require inkrot/php-compress-json and commit the updated composer.json and composer.lock. Because the upstream repository is not publicly documented in the information available, verify the resolved package source and version before merging. Check whether it declares extension requirements such as ext-json or ext-zlib and make sure those extensions exist in your production images. Run composer why inkrot/php-compress-json afterwards to confirm nothing unexpected was pulled in.
How should I wire it into Eloquent, a custom cast or a repository layer?
Either works, but keep the package behind your own JsonCodec or CompressedJson interface so it can be swapped for gzcompress, zstd, or a forked version later. A custom cast is convenient for a single model attribute; a repository or serializer method is better when several payload types share the same format and version marker. Avoid calling the library directly from controllers and jobs, since that spreads the dependency everywhere. Add a format or version marker alongside the compressed value so future readers know how to decode it.
Does it round-trip losslessly, including Unicode, big integers, floats, nulls, and key ordering?
The library is described as lossless, meaning the restored payload should match what you compressed, but you must verify this against your own edge cases. Test with UTF-8 and multibyte strings, integers beyond PHP's native precision, floats that stringify differently, nulls, empty arrays versus empty objects, and deeply nested structures. Also check whether key ordering and whitespace are preserved or normalized, because either can break naive equality checks or payload hashes. Run a round-trip assertion over a sample of real production payloads before committing to the format.
Which PHP and Laravel versions does inkrot/php-compress-json support?
This is not clearly documented in the information available, so validate the composer.json require constraints against your target stack before adoption. Check the required PHP version, any extension dependencies, and whether conflicts exist with packages already in your lock file. Since the package does not appear to be Laravel-specific, Laravel version support mostly reduces to whether your PHP version satisfies its constraints. Test on every PHP version and deployment image your team actually runs, not just your local machine.
Can I store the compressed output in a native JSON column and still query it?
Probably not, and you should not plan on it. If the compressed output is binary, it cannot go into a native JSON column without losing queryability, JSON path indexes, and generated columns. Store compressed values in a binary-safe TEXT/BLOB or bytea column instead, and keep queryable fields in regular columns if reporting or filtering needs them. If the library's output happens to remain valid JSON, verify that carefully, but assume queryability is lost until proven otherwise.
Is it safe to decode untrusted or malformed payloads?
Only decode payloads your application wrote, or validate and bound them first. Compressed data is a classic decompression-bomb vector, so cap the maximum decompressed size and wrap decode calls in try/catch with a clear failure path. Confirm how the library behaves on truncated, corrupted, or attacker-controlled input, and whether it throws a catchable exception or emits warnings. Never let a decode failure take down a request or job without a fallback or alert.
Is it production ready given the low adoption and unknown repository?
Treat the risk as medium-to-high until due diligence is complete. The key concerns are an upstream repository that is not publicly inspectable, very low community validation (around 10 stars), unclear PHP and Laravel support, and uncertain long-term maintenance. There is no confirmed evidence of tests, CI, static analysis, or a security policy, so plan for a vendor fork and a format-versioning strategy. Do not put it on a critical path without a rollback plan and a way to decode old payloads after future upgrades.
What are the alternatives, and how do I migrate existing JSON data safely?
PHP's built-in gzcompress or gzencode, or zstd via ext-zstd, will cover most JSON-at-rest compression needs with no third-party dependency, and you can wrap them in the same codec interface. If you adopt the package, roll it out with dual-read/dual-write on one low-risk table behind a feature flag, backfill in bounded batches with checksum and round-trip validation, then cut reads over and monitor decode failures and latency. Keep legacy JSON writable until a defined soak period ends so you can roll back quickly. Never do a big-bang migration of high-value data.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo