stevebauman/purify
Laravel wrapper for HTMLPurifier to sanitize user-submitted HTML. Clean strings or arrays via a simple facade, with support for dynamic per-call configuration, published config, and caching options to keep output safe and consistent.
data-trix-*).comments, posts).strip_tags, regex) with a declarative, Laravel-native solution, reducing technical debt.<figure> for Trix).Adopt if:
Look elsewhere if:
strip_tags() suffices.<script> tags in SPAs)."This package lets us safely enable rich user content (e.g., formatted comments, editor posts) without exposing our app to XSS attacks. It’s like a ‘security firewall’ for HTML input—automatically blocking malicious scripts while preserving safe formatting. For example, we can let users write in Trix or CKEditor without worrying about hackers injecting code. It’s already used by high-traffic sites and integrates seamlessly with Laravel, reducing dev time and risk."
Key Outcomes:
*"This is a batteries-included Laravel wrapper for HTMLPurifier, the gold standard for HTML sanitization. It solves:
comments, posts).Why not roll our own?
Example Use Cases:
data-trix-* attributes).Trade-offs:
Next Steps:
composer.json and publish the config.config/purify.php).PurifyHtmlOnGet cast for Eloquent models or call Purify::clean() manually.Let’s demo how it handles a malicious payload vs. safe Trix HTML!"*
How can I help you explore Laravel packages today?