- How do I install overtrue/laravel-text-guard in a Laravel application?
- Install it with Composer using composer require overtrue/laravel-text-guard. Laravel package discovery registers the service provider and facade automatically, so no manual registration is normally needed. If the package ships a config file, publish it with php artisan vendor:publish and review the defaults before using it in production. Check the package's composer.json constraints for PHP and illuminate/* versions before scheduling the upgrade.
- Which Laravel and PHP versions does laravel-text-guard support?
- Release 1.0.4 adds Laravel 13 support as a framework-compatibility bump, widening the supported matrix rather than changing behaviour. The technical assessment positions the package for Laravel 10 through 13, but you should confirm the exact PHP and illuminate/* ranges against the package's composer.json rather than release notes. If you still run an older Laravel or PHP version, verify constraints first because the 1.0.4 change may have moved the minimum supported versions.
- How do I use laravel-text-guard as a validation rule?
- The package is designed to work as a Laravel validation rule, so you add its rule class to a field's rule array in a FormRequest rules() method or a Validator::make() call. That lets you reject comments, profiles, messages, or listings that contain banned or sensitive content at the request boundary. Keep the rule in your own form request classes rather than scattering it across controllers. Review the package's rule options in the published config to tune strictness for each field.
- Can I use laravel-text-guard as a standalone utility outside validation?
- Yes. The package is described as both a validation rule and a standalone string sanitization and normalization utility. You can resolve the underlying service from the container or use the facade to scan or clean a string inside a job, console command, or domain service. Wrapping those calls behind your own ModerationService interface keeps the package out of your domain code and makes it easy to swap later.
- How do I configure the banned or sensitive word list in laravel-text-guard?
- Configuration follows the standard Laravel package idiom, so publish the config file with php artisan vendor:publish and edit the word list and filtering options it exposes. Keep your own curated list in version control so changes are reviewable and testable rather than edited directly on a server. Because moderation quality depends on the dictionary and matching rules, validate changes against a labelled corpus of real examples before deploying. Confirm the exact config keys in the published file, since 1.0.x releases may still adjust them.
- Does laravel-text-guard handle multilingual text and Unicode obfuscation such as zero-width characters or homoglyphs?
- The supplied material does not document multilingual coverage or Unicode normalization, and this is flagged as an open question in the technical assessment. Text-guard libraries are heuristic by nature, so false positives and false negatives are expected to some degree. Before relying on it, test the package against your own corpus with zero-width characters, homoglyphs, mixed scripts, and spaced-out or leetspeak variants. If coverage is insufficient, add a normalization step in front of the check rather than patching the package.
- Is laravel-text-guard safe to call on the hot path of write requests?
- Any moderation package becomes a synchronous dependency on the write path, so latency matters where budgets are tight. Wrap the package behind your own ModerationService interface so you can call it inline for cheap checks and dispatch it to a queue where appropriate. Decide your failure mode explicitly, for example failing open with a review queue or failing closed with a validation error, and test that behaviour. Local dictionary matching is typically cheap, but confirm the mechanism, since an external moderation API would add latency, quota, and data-residency concerns.
- How can I test moderation behaviour in my own test suite, and does the package provide a fake?
- The supplied material does not confirm whether the package ships a test fake or stub, so assume it does not until you verify. The reliable approach is to hide it behind your own ModerationService interface, bind a fake implementation in your test suite, and assert that your application reacts correctly to blocked and allowed verdicts. Keep a small set of known-banned and known-clean strings for integration tests that exercise the real package. That combination gives you fast unit tests and a thin layer of confidence in the underlying matcher.
- What are the alternatives to overtrue/laravel-text-guard for filtering user-generated content?
- Alternatives include a hand-rolled regex or keyword filter, another Laravel profanity or moderation package, or a dedicated moderation API for higher accuracy on nuanced content. A local dictionary approach is cheap and private but weak against obfuscation and multilingual input, while external APIs add latency, cost, and data-sharing considerations. Many teams combine a fast local pre-filter with escalation of borderline cases. Because the package is a young 1.0.x project with a single maintainer, keeping your own interface in front of whichever option you pick reduces lock-in.
- Is overtrue/laravel-text-guard production ready and actively maintained?
- It is a 1.0.x package with a patch-level release history, showing active maintenance but also signalling a young public API that may still change across minor versions. The release is authored by the package maintainer @overtrue, and the supplied material shows no co-maintainer group or published security policy, so treat it as a single-maintainer dependency. For production, pin the version in composer.json, review the changelog before upgrades, and isolate it behind your own interface. Also track false-positive and false-negative rates, since moderation accuracy is a product risk that package releases do not address.