psx/data
psx/data provides a lightweight model and data-processing layer for PHP: records, collections, readers and writers that map data from HTTP, SQL, files and arrays into typed objects, with validation, filtering, hydration and transformation built in.
composer require psx/data and immediately check the installed version and PHP constraint with composer show psx/data.README.md for the supported reader/writer/processor flow.src/ for the actual interfaces and concrete reader/writer classes.tests/ for working payload-to-POPO examples, especially nested objects, arrays, dates, and null handling.Typical first endpoint shape:
use PSX\Data\Reader\Json as JsonReader;
use PSX\Data\Writer\Json as JsonWriter;
$reader = new JsonReader();
$writer = new JsonWriter();
$payload = $reader->read($request->getContent());
// The processor class/API varies by version; verify against vendor/psx/data/src.
$dto = $processor->process($payload, CreateOrder::class);
return response(
$writer->write($dto),
200,
['Content-Type' => 'application/json']
);
If the processor constructor has dependencies, bind it in a Laravel service provider rather than constructing it ad hoc in controllers. Keep the first integration small: one DTO, one reader, one writer, one round-trip test.
Content-Type and a writer from Accept/route suffix. This is where psx/data is most useful: JSON, XML, CSV, or other formats feeding the same POPO layer.read -> process -> write and write -> read fixtures. Include nested objects, arrays of objects, empty arrays, null, missing fields, and date/time values.JsonReader/JsonWriter, XmlReader/XmlWriter, or a CSV writer based on request headers. Unknown formats should return 406 Not Acceptable, not fall through to an accidental default.composer.json and isolate usage behind a small adapter layer.src/. The package’s processor/reader/writer names and constructor signatures may differ from examples found online. Use composer show psx/data, inspect vendor/psx/data/src, and follow the tests rather than guessing."1" to 1 or turn missing values into null. Validate required fields and ranges explicitly before business logic.null, an empty array, and an empty string often take different paths in mapping and serialization.=, +, -, or @.422 validation-style responses. Do not let raw serialization errors become 500 responses or leak internal class names.response() with the correct Content-Type; do not echo it directly from a controller or middleware.psx/data behind an application-level PayloadMapper interface. If the package becomes unmaintained or conflicts with a future Laravel/Symfony upgrade, you can swap in Symfony Serializer or manual mapping without rewriting controllers.How can I help you explore Laravel packages today?