beste/json
JSON helpers for PHP and Laravel: decode/encode, safe access, casting, and convenient manipulation of JSON strings and arrays. A lightweight utility package focused on cleaner, less error-prone JSON handling in everyday applications.
composer require beste/json.JsonEncoder and JsonDecoder classes—lightweight, static-friendly wrappers around PHP’s json_encode and json_decode, with sensible defaults (e.g., JSON_THROW_ON_ERROR, JSON_INVALID_UTF8_SUBSTITUTE).json_encode($data, JSON_THROW_ON_ERROR) calls with JsonEncoder::encode($data) for cleaner, safer, and more readable code.JsonEncoder::encode($payload) over json_encode($payload) to signal structured JSON handling.JsonDecoder::decode(string $json, bool $associative = true, int $depth = 512, int $flags = 0) and leverage typed properties or DTOs:
$user = JsonDecoder::decode($json, true, 512, JSON_THROW_ON_ERROR);
$dto = UserDto::fromArray($user);
try/catch (\JsonException) where needed, or rely on JSON_THROW_ON_ERROR (enabled by default in decode methods).JSON_THROW_ON_ERROR and JSON_INVALID_UTF8_SUBSTITUTE by default—don’t override JSON_PARTIAL_OUTPUT_ON_ERROR unless you really need fallback output (strongly discouraged in production).webmozart/json) if strict schema enforcement is needed.encode()/decode() for edge cases (e.g., JSON_PRETTY_PRINT for debugging logs).Beste\Json namespace—avoid use clashes with custom aliases.How can I help you explore Laravel packages today?