toshy/validation-bundle
toshy/validation-bundle provides reusable validation rules and helpers for PHP applications, helping keep form, request, and data validation clean, consistent, and easy to maintain. It reduces duplicated validation logic across your project.
Start by understanding what this package is: toshY/validation-bundle is a Symfony bundle, not a Laravel package. It hooks into Symfony's Kernel and DI container, registers services via config/packages/, and ships a *Bundle class that must be added to config/bundles.php. None of that machinery exists in Laravel, so there is no composer require + php artisan vendor:publish path here.
What a Laravel developer should actually do first:
src/ — the constraints, validators, and any custom rule logic.Illuminate\Validation covers a huge amount of ground, and Laravel 11/12 already pulls in symfony/validator transitively via the framework. Confirm you aren't about to duplicate what Rule, ValidationRule, or the Validator facade already give you.symfony/validator directly, instantiate Symfony\Component\Validator\Validation::createValidator() in a service provider, and register the constraints manually — the bundle registration step disappears entirely.Rule object, then validating through Validator::make() like any other rule. This is where the "leverage" is — not in the bundle, but in borrowing its constraint implementations.The first thing to check in the repo is composer.json: if the require block pins symfony/*: ^8.0 only, you may be forced onto Symfony 7.x-compatible tags for use with older Laravel versions that ship Symfony 6/7 components.
Because this isn't a Laravel-native package, integration patterns fall into three buckets.
1. Drop-in constraint reuse (most common).
Copy or composer require only the pieces you need and register them as Laravel rules:
// app/Rules/Iban.php
class Iban implements ValidationRule
{
public function validate(string $attribute, mixed $value, Closure $fail): void
{
$validator = Validation::createValidator();
$violations = $validator->validate($value, [new \App\Vendor\Constraints\Iban()]);
if (count($violations) > 0) {
$fail($violations[0]->getMessage());
}
}
}
Wire this into a RuleSet or use it inline via 'iban' => [new Iban()].
2. Standalone Validator service binding (for teams that want Symfony's constraint ecosystem in Laravel). Bind a shared validator instance in a service provider:
$this->app->singleton(ValidatorInterface::class, fn () => Validation::createValidator());
Then inject it into form requests and map violations to Laravel's MessageBag. This gives you access to Symfony's full constraint library (Luhn, IBAN, ISBN, UUID, ULID, currency, locale, etc.) that Laravel doesn't ship out of the box.
3. Translation/attribute bridging.
Symfony constraints use annotations/attributes and a translator. If you use the attribute-based constraints, ensure you've configured a translator and that messages resolve through Laravel's lang/ files (or let them stay in Symfony's domain — usually fine, since the messages are English defaults).
4. Cross-framework validation layer in a monorepo. If your team runs Symfony services and Laravel services side-by-side, this bundle is the Symfony side of a shared validation contract. Adopt the constraint names/attributes consistently on both sides so DTOs can share meaning — but don't try to share the bundle itself.
type: symfony-bundle in composer.json will not auto-register anything in Laravel. Bundle classes require Symfony\Component\HttpKernel\Bundle\Bundle and are wired through Kernel::registerBundles(). Don't expect php artisan about to show it.composer require toshy/validation-bundle in a Laravel app just to borrow constraints, Composer will try to install the full bundle (including Symfony kernel deps you already have via Laravel, possibly at incompatible versions). Prefer extracting the code, or add an explicit "symfony/framework-bundle": "conflict" in the root composer.json if you must vendor it.validators translation domain. Laravel's translator won't know that domain by default — expect untranslated English messages unless you copy the .xlf files into Laravel's lang/ tree.ContainerBuilder compiler passes (tagged services, !tagged_iterator, etc.) will silently not be available. If you copy code that depends on tags, you must replicate the wiring manually in a service provider.locale — Symfony's constraints sometimes branch on translator locale for message selection, and the default en in Laravel may differ from your configured Symfony locale.ValidatorBuilder (accessible via Validation::createValidatorBuilder()) is where you register custom validators without the bundle. That single line is the entire value the bundle's DI configuration would otherwise give you.Bottom line for a Laravel shop: treat this as a source of reusable constraint implementations, not an installable package. Add it to your "look here for validation rules we don't have" list, keep an eye on the 2.2.0 PHP 8.4 floor, and vendor/extract rather than require.
How can I help you explore Laravel packages today?