cuyz/valinor
Valinor maps raw inputs (JSON/arrays) into validated, strongly typed PHP objects. Supports advanced PHPStan/Psalm types (shaped arrays, generics, ranges), produces precise human-readable errors, and can normalize data back to formats like JSON or CSV.
request()->input()) with type-safe alternatives.spatie/array-to-object, symfony/serializer, or laravel/validation by offering a more performant, type-driven alternative.#[FromRoute], etc.), which may necessitate team training.json_decode + manual validation).MappingError exceptions must be mapped to Laravel’s exception handling (e.g., App\Exceptions\Handler) to ensure consistent API responses.$request->validate()) or augment it (e.g., for DTOs)?MappingError exceptions be translated into Laravel’s error format (e.g., JSON API errors)?request()->route('id') → #[FromRoute] int $id).#[FromBody(asRoot: true)] for Request objects).Valinor\Normalizer for JSON payloads).public function store(Request $request) {
$data = $request->validate([
'name' => 'string|max:255',
'email' => 'email',
]);
// ...
}
To:
public function store(#[FromBody] UserCreationDto $data) {}
MappingError exception handler in App\Exceptions\Handler.Request objects (attributes replace manual parsing).json_decode with MapperBuilder).validate() arrays).json_decode + manual validation for critical paths.MapperBuilder instances for repeated mappings (e.g., in middleware).Normalizer for batch operations (e.g., exporting 1000+ records).User[] → array<UserDto>).MappingError: Catch and translate to Laravel’s HttpResponse with appropriate status codes (e.g., 422 Unprocessable Entity).catch (MappingError $e) {
return response()->json([
'errors' => $e->getErrors(),
], 422);
}
int is expected) will fail fast.#[FromQuery] ?int $page = 1).How can I help you explore Laravel packages today?