cuyz/valinor
Valinor maps raw input (JSON/arrays) into fully typed PHP objects, validating along the way with clear, human-readable errors. Supports advanced types (PHPStan/Psalm), shaped arrays, generics, ranges, and can normalize objects back to JSON/CSV while preserving structure.
Adopt if:
Look elsewhere if:
*"Valinor is a dependency-free PHP library that turns messy, untrusted input (like API requests or CSV files) into guaranteed, strongly-typed objects—automatically. This:
isset() checks or try-catch blocks for every input).ROI Ask: "Would you prioritize reducing API-related bugs or accelerating data pipeline development?"
*"Valinor lets you map raw input to typed objects with zero boilerplate, while catching errors via PHPStan/Psalm (static analysis) or runtime validation. Key benefits:
array_key_exists() hell: Define your DTOs with PHPDoc types (e.g., non-empty-string, list<City>), and Valinor handles the rest.Example:
// Before: Manual validation + mapping
if (!isset($data['name']) || !is_string($data['name'])) throw new \InvalidArgumentException();
$country = new Country($data['name'], ...);
// After: One line with validation
$country = $mapper->map(Country::class, $data); // Throws on error
Use it for:
Tradeoffs:
Next Steps:
How can I help you explore Laravel packages today?