choz/request-validation-bundle
Validator component, dependency injection, and event system. This makes it a natural fit for Symfony-based applications, especially those already using Symfony’s validation or form components.FormRequest or manual validation, reducing cognitive load while abstracting Symfony’s complexity.symfony/json-request-bundle) and structured error responses, aligning with modern backend architectures.bundles.php setup and potential DI adjustments.Validator component (included by default in Symfony) and optionally symfony/json-request-bundle for JSON payloads. No conflicts with Laravel-specific packages.@Assert\*, custom validators), enabling reuse of existing validation logic or libraries (e.g., API Platform’s constraints).public function create(TagCreateRequest $request): JsonResponse { ... }
FormRequest or manual validation, with 1:1 syntax mapping (e.g., rules() method → Symfony constraints).Collection, Callback, Expression) to leverage advanced features. Risk: Steeper learning curve for teams unfamiliar with Symfony’s validator.
Required, Type, Length) before advanced use.Validator facade or FormRequest will need to rewrite validation logic or maintain dual implementations.
CustomRequestValidationEventListener or override the response_code config.groups option) to skip unnecessary validations in performance-critical paths.Validator component for upstream changes.Validator component? If not, what’s the learning curve tolerance for constraints?Validator component (already included).symfony/json-request-bundle).Validator and DI container.| Current State | Migration Path | Effort |
|---|---|---|
Laravel FormRequest |
Replace FormRequest with BaseRequest; rewrite rules() to use Symfony constraints. Example: new Required() instead of 'required'. |
Medium |
| Manual Laravel validation | Replace Validator::make() with BaseRequest classes. Example: Move validation logic from controller to a CreateUserRequest class. |
Low-Medium |
Symfony Validator component |
Adopt BaseRequest for DRY validation in controllers. Example: Inject UserCreateRequest instead of manually validating $request->request. |
Low |
| No validation | Introduce BaseRequest for new endpoints; incrementally replace manual checks (e.g., if ($request->has(...))). |
Low-Medium |
| Custom validation libraries | Replace ad-hoc libraries with Symfony constraints (e.g., new Assert\Email()). Leverage existing Validator extensions. |
Medium-High |
symfony/json-request-bundle for automatic JSON parsing. Install separately:
composer require symfony/json-request-bundle
@Assert\All, @Assert\Callback). No additional setup needed.kernel.exception events. Example: Override default error responses for GraphQL APIs./health or /debug).BaseRequest.POST /users, PUT /products).BaseRequest for new features.BaseRequest classes.Validator).config/packages/choz_request_validation.yaml (e.g., response codes, event listeners).Validator component for breaking changes (e.g., constraint API updates). Mitigation: Pin Symfony version in composer.json.How can I help you explore Laravel packages today?