Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Php Validator

Php Validator Laravel Package

fangstar/php-validator

A lightweight, framework-agnostic PHP validation library with a familiar Laravel-style rule syntax. Validate arrays and request data using built-in rules, custom messages, and nested fields, plus support for custom validators—no framework required.

View on GitHub
Deep Wiki
Context7

fangstar/php-validator is a lightweight, framework-agnostic validation library for PHP that brings Laravel-style rule syntax to any project. Define rules as arrays or strings, validate incoming request data, and retrieve clear, customizable error messages—without pulling in a full framework.

  • Fluent rule sets for common checks like required, email, numeric, length, and regex
  • Custom messages and field labels for user-friendly errors
  • Scene-based validation to apply different rule groups per context
  • Zero framework dependencies—works in plain PHP and Laravel
  • Extensible rules via custom validators
Frequently asked questions about Php Validator
Is fangstar/php-validator a Laravel package?
No. It is a framework-agnostic PHP validation component; the repository ships no Laravel ServiceProvider, Facade, or ValidatorFactory implementation. In a Laravel app it would run alongside Illuminate's validator, not replace it. That means two rule syntaxes and two error-message paths unless you add an adapter.
How do I install fangstar/php-validator with Composer?
Install it with composer require fangstar/php-validator and include Composer's autoloader. The package is standalone, so no Laravel provider registration is required. Check the package's PHP constraint first; the last release dates from 2016, so modern PHP compatibility must be verified before use.
Does fangstar/php-validator work with Laravel 10 or 11?
There is no official Laravel integration, so it will not plug into FormRequests, the 422 JSON contract, or lang files by itself. It might run as a plain PHP dependency if it is PHP 8 compatible, but that is not guaranteed given its 2016 release date. You would need a thin adapter and boundary translation to use it safely in Laravel 10 or 11.
How does fangstar/php-validator compare to Laravel's Validator?
Laravel's validator already covers presence, type, nested array, conditional, and custom Rule validation with a mature error contract and localization. fangstar/php-validator offers a simpler standalone rule DSL but lacks Laravel's ecosystem integration, maintenance cadence, and framework-level exception handling. For most Laravel endpoints, using Laravel's validator is the lower-risk choice.
Can I use Laravel-style validation rules outside Laravel?
Yes, that is the library's main appeal: it provides familiar rule syntax in plain PHP projects without requiring the framework. You still need to confirm the exact rule set and PHP version support in the source, because the package predates modern PHP releases. It is best suited to small scripts, CLI tools, or isolated services rather than a framework's shared HTTP kernel.
Does fangstar/php-validator support custom error messages and nested data?
The package blurb advertises custom messages and nested data validation, which are common reasons developers look for a standalone validator. Verify the actual rule coverage and message shape against your API error envelope before adopting it. In Laravel, you would also need to map its output into MessageBag or ValidationException for consistency.
Is fangstar/php-validator maintained and PHP 8 compatible?
The last release was 2016-11-23, it has roughly 32 stars and no dependents, and there is no visible CI, test suite, or security process in the package metadata. It predates PHP 7.1, so PHP 8 compatibility is likely to require code edits and testing. Treat it as unmaintained unless you are prepared to fork and own it.
How should I integrate fangstar/php-validator into a Laravel app?
Do not call it directly from controllers. Define an internal ValidationService contract, implement it first with Laravel's validator, and make fangstar/php-validator one optional driver behind that seam. Confine it to a non-critical bounded surface and translate its results into Laravel's MessageBag or ValidationException at the boundary.
Can fangstar/php-validator validate API JSON input?
It can validate arrays or input data in plain PHP, so JSON decoded into an array can be passed to it. The risk is not basic validation but integration: status codes, error envelopes, localization, and exception handling must be standardized with the rest of your API. For Laravel APIs, the built-in validator plus custom Rule classes usually covers this with less bespoke code.
What are alternatives to fangstar/php-validator?
For Laravel projects, use Illuminate's Validator, FormRequests, and custom Rule objects first. For framework-agnostic PHP, consider actively maintained libraries such as Respect\Validation or Symfony Validator, or write a small custom validator if your rules are limited. fangstar/php-validator is more useful as a reference implementation than a production dependency.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource