- How do I install PureText in a Laravel application?
- Install it with Composer using composer require yasser-elgammal/pure-text, then publish the package configuration with the provided publish command. Register the service provider if your Laravel version does not auto-discover it, add your word lists to the published config, and attach the middleware only to routes that handle user-generated content. A typical rollout is install, publish config, seed the lexicon, then wire middleware and the Blade directive.
- Which Laravel and PHP versions does PureText support?
- The package is built on modern Laravel service provider, config, and middleware contracts, so it should slot into current Laravel applications, likely Laravel 9+ with PHP 8.1+. Do not trust a constraint blindly: check composer.json and Packagist for the actual requirement, then run the package suite against your exact Laravel and PHP versions in a spike. For credible Unicode and Arabic handling, treat ext-mbstring and ext-intl as hard prerequisites on the target runtime.
- How does PureText filter unwanted words in model attributes?
- PureText applies a configurable term-matching and replacement pipeline to model attributes, swapping matched terms according to your configured replacement strategy. You define the word lists and replacement behavior in the published config, then invoke the filtering through the package's facade-style API or automatic model-attribute path. It is a mechanics layer, so you own the lexicon and decide the false-positive budget per surface.
- Does PureText support Arabic and other languages?
- The package advertises multilingual and Unicode support, including Arabic content, through its word-list and normalization pipeline. Before relying on it, verify that the Arabic path normalizes alef and hamza variants, tatweel, diacritics, and Arabic-Indic digits before matching rather than only stripping them afterward. Run your own normalization edge-case tests, because that is exactly where this class of package tends to break.
- Can I customize the unwanted-word list and replacement text?
- Yes. Publish the package config and populate your own term lists and replacement strings; the filtering mechanics are separate from the dictionary content. Treat the bundled lexicon as a starting point you own from day one, and diff any existing in-house blacklist against it to avoid silent coverage loss. Confirm whether the package supports per-context strategy overrides or only global configuration before designing multi-surface behavior.
- How do I filter incoming requests with PureText middleware?
- Register the package middleware on the routes that ingest user-generated content, not globally, so you do not pay the matching cost on every request. The middleware is the natural place to sanitize request input before it reaches your controllers and validation layer. Keep a shadow or log-only mode for a couple of weeks to tune false positives before you start rewriting payloads.
- How do I use PureText in Blade templates?
- The package ships a Blade directive that lets you render filtered text at output time, which is useful for comments, chat, and other user-authored content. Wire it only into the views that actually render untrusted text, and keep the input-side middleware as the primary defense. Output filtering is a second layer, not a replacement for request-level sanitization.
- What is the performance impact of filtering thousands of terms?
- Regex-per-request matching against a large list can degrade quickly, especially at five thousand terms or more, so benchmark cold-start and per-request cost on your target runtime. If the numbers are poor, look at a compiled or cached matcher and add a request-size guard to limit backtracking exposure. The package is lightweight, but the matching strategy, not the install size, is what determines production cost.
- Does PureText catch leetspeak, spacing tricks, and homoglyph evasion?
- Partially at best. Leetspeak, inserted spacing, diacritics, tatweel, and homoglyphs are an arms race that no static word list wins, so treat PureText as one layer in a broader moderation stack. Normalize aggressively before matching, maintain an allowlist, and keep human review or a moderation service for high-risk surfaces. Measure the evasion rate you are willing to accept rather than assuming full coverage.
- Is PureText production-ready given its small maintainer footprint?
- Treat it as a mechanics layer behind your own TextFilter interface rather than an out-of-the-box policy engine. The package has a single maintainer, low star count, and zero dependents, so fork-and-own is the realistic posture: pin the version, wrap it, and be ready to maintain your fork. Reconcile release metadata against Packagist and git tags, and verify CI and test transparency before trusting the Unicode claims.