alexanevsky/input-manager-bundle
Strengths:
InputInterface objects, and domain models (e.g., Doctrine entities). This aligns well with Domain-Driven Design (DDD) and Clean Architecture principles by treating input as a distinct layer.Article with Category[]), which is critical for APIs with hierarchical payloads.EntityFromId attribute simplifies fetching related entities (e.g., Category by id), reducing manual repository calls in controllers.Weaknesses:
Validator, TranslatableMessage), which may complicate adoption in non-Symfony Laravel projects (though Laravel has similar equivalents).InputInterface/InputModifiableInterface, which may feel restrictive for teams with existing DTO patterns.symfony/validator and symfony/translation packages can be installed to replicate Symfony’s validation ecosystem.InputManager can be registered as a Laravel service provider (e.g., via register() in a custom provider).Request object by converting it to JSON/array before deserialization.FormRequest validation but adds an extra layer for complex transformations.EntityFromId).TranslatableMessage) require translation setup, which may not align with Laravel’s localization systems.InputManager and validators in unit tests demands careful setup.FormRequest or manual validation may resist adopting this layer.Validator facade)?EntityFromId.TranslatableMessage?InputManager and custom validators be mocked in unit tests?Request object to JSON/array before deserialization:
$json = json_encode($request->all());
$input = $this->inputManager->deserializeInput($json, UserInput::class);
// app/Providers/InputManagerServiceProvider.php
public function register()
{
$this->app->bind(InputManager::class, function ($app) {
return new InputManager(
$app->make('validator'),
// Other dependencies...
);
});
}
Validator facade with Symfony’s validator (if needed):
// config/app.php
'aliases' => [
'Validator' => Symfony\Component\Validator\Validator\ValidatorInterface::class,
];
composer require symfony/validator symfony/translation
TranslatableMessage):
# config/packages/translation.yaml
frameworks:
translation:
paths: ['%kernel.project_dir%/translations']
EntityFromId works out-of-the-box.EntityFromId resolver or use a trait to bridge the gap.UserController@store) to test deserialization/validation.FormRequest validation.InputInterface classes for complex payloads.FormRequest to AbstractInputValidator.InputManager across all API controllers.if checks).| Laravel Feature | Compatibility | Workaround |
|---|---|---|
| Form Requests | Low (competing abstraction) | Use InputManager for transformation, keep FormRequest for validation. |
| API Resources | Medium (no native support) | Create adapters to convert InputInterface to API resource data. |
| Eloquent | Medium (requires EntityFromId customization) |
Use a trait to resolve Eloquent models by ID. |
| Laravel Validation | High (can wrap Symfony validator) | Extend Validator facade to delegate to Symfony’s validator. |
| Queue Jobs | High (works with serialized payloads) | Ensure InputInterface is serializable (e.g., implements JsonSerializable). |
| Livewire/Inertia | Low (not designed for frontend frameworks) | Use for backend API layers only. |
InputInterface/InputModifiableInterface classes for critical payloads.deserializeInput() in controllers/services.Mapper component to populate Doctrine/Eloquent entities.TranslatableMessage.How can I help you explore Laravel packages today?