- How do I install ivanbaric/sanigen in a Laravel application?
- Install it with Composer using composer require ivanbaric/sanigen. Laravel package discovery registers the service provider automatically, and you can publish any package configuration if your application needs to customize defaults. After installation, use the Artisan generator to scaffold your first sanitizer class and apply it in a form request, model event, or dedicated sanitization service.
- Which PHP, Laravel, and Spatie Translatable versions does Sanigen support?
- Sanigen is built for modern Laravel applications, and version 1.9.0 adds first-class support for Spatie Translatable through the HasSanitizedTranslations trait. The exact PHP, Laravel, and Spatie Translatable constraints should be checked in the package composer.json and release notes before upgrading. Confirm those constraints in staging, especially if your application pins older Laravel or PHP versions.
- Does Sanigen run before or after Laravel validation?
- Sanigen is intended for the write path, so it is typically applied before validation in a form request or before persistence in a model event or service. It cleans and normalizes incoming request data, but it does not replace Laravel validation rules. Use both together: sanitize first for predictable input, then validate the normalized values.
- How do I register a custom sanitizer and control its order with built-in aliases?
- Scaffold a sanitizer class with the Artisan generator, then compose rules through the fluent, chainable API and add custom rules for domain-specific cleanup. Built-in filters cover trimming, tag stripping, whitespace normalization, and type casting. When a custom rule overlaps a built-in alias, verify ordering in the package configuration and test the resulting pipeline so the intended rule wins.
- What happens when Sanigen fails closed on invalid input or paths?
- Version 1.9.0 fails closed for objects, resources, malformed paths, and equal-specificity conflicts instead of silently passing unsafe values through. Structured processing is atomic and designed to avoid leaking submitted values in exception messages. The exact exception type and logging behavior should be confirmed in the package tests or documentation, then mapped to validation errors or application logging as needed.
- Can Sanigen sanitize JSON columns, nested arrays, and wildcard paths?
- Yes. Sanigen 1.9.0 supports structured recursive sanitization across ordinary attributes, JSON columns, and nested arrays, with dot-notation and wildcard paths for heterogeneous JSON shapes. Root sanitizer rules now recurse automatically, and each string leaf receives one matching pipeline. Use wildcard rules only for JSON shapes you know, and test representative payloads before enabling them broadly.
- How should I upgrade from Sanigen 1.8.x to 1.9.0?
- Upgrade incrementally: update the dependency, run your existing test suite against representative payloads, and pay special attention to JSON columns and translatable fields. Root rules now recurse automatically, which can change output for configurations that relied on the old non-recursive behavior. Keep the deprecated recursive: prefix during the transition because it remains backward-compatible, then remove it in a later cycle.
- Are Sanigen depth, item-count, and scalar-length limits configurable per model or globally?
- Sanigen 1.9.0 adds shared depth, item-count, and scalar-length limits to bound recursive sanitization and reduce risk on large payloads. Whether these are configured globally or per sanitizer or model depends on the published configuration, so check the config file and release notes before relying on per-model overrides. Treat the defaults as production safeguards and tune them only after measuring your largest JSON payloads.
- Does Sanigen support Spatie Translatable fields?
- Yes. Sanigen 1.9.0 introduces the HasSanitizedTranslations trait, making Spatie Translatable support a real integration rather than custom application glue. Add the trait where you already use Spatie Translatable, then let the sanitizer clean translated string values as part of structured recursive processing. Confirm the supported Spatie Translatable version in the package constraints before rolling it out.
- Is Sanigen production-ready, and how is it tested?
- Sanigen 1.9.0 ships with 138 tests and 405 assertions, which is a strong signal for a library-level package, but it does not replace application-specific regression coverage. Run your own payload tests for JSON columns, translatable fields, and any custom rules before production enablement. Sequence the rollout through dependency upgrade, non-production regression, targeted JSON and translation tests, then canary or staging before production.