axy/codecs-base64vlq
PHP codec for Base64 VLQ (variable-length quantity) encoding/decoding of integer sequences, suitable for compact text representations (e.g., JavaScript/CSS source maps). Converts signed ints to VLQ digits and maps them into Base64 characters.
json_encode()/json_decode() for hybrid use cases.Str::of() or Cache) require validation.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Custom Alphabet Errors | High | Validate alphabets during config phase (e.g., Encoder::validateAlphabet()). |
| VLQ Decoding Failures | Medium | Wrap decode() in try-catch for InvalidVLQSequence. |
| Performance Overhead | Low | Benchmark vs. native json_encode() for target use cases. |
| Laravel Ecosystem Gaps | Low | No Laravel-specific features; use as a utility. |
InvalidVLQSequence trigger Laravel’s ProblemDetails response (API) or log silently?gzip + json_encode() for the same data.AppServiceProvider for global access:
$this->app->singleton(Encoder::class, fn() => Encoder::getStandardInstance());
Base64VLQ facade for fluent syntax:
use Facades\Base64VLQ;
$encoded = Base64VLQ::encode([1, 2, 3]);
$this->app->bind(Encoder::class, fn($app) => new Encoder(
$app['config']['vlq.alphabet'],
$app['config']['vlq.bits']
));
json_encode() call in a high-volume endpoint with Encoder::encode().Illuminate\Cache\Store).Arrayable trait to support VLQ encoding:
public function toVLQArray(): array { return $this->encodeVLQData(); }
laravel-codecs-vlq) with:
.env.@vlqEncode).TEXT/VARCHAR fields (unlike binary formats). Avoid for BLOB use cases.config/vlq.php before app boot.FallbackEncoder (e.g., json_encode()) for unsupported data.InvalidVLQSequence/InvalidBase64 with context (e.g., input data).xdebug support for VLQ digit inspection.| Scenario | Impact | Mitigation |
|---|---|---|
| Corrupted VLQ input | Decoding fails | Fallback to json_decode() |
| Custom alphabet misconfig | Runtime errors | Validate alphabet length vs. bits |
| Large integer overflow | Silent data loss | Add max_int_size config option |
| Concurrent encoding races | None (stateless) | N/A |
gzip).php artisan vlq:benchmark [data-file]
How can I help you explore Laravel packages today?