pragmarx/ia-str
Framework-agnostic extraction of Laravel’s Illuminate\Support\Str and string helper functions, repackaged under IlluminateAgnostic\Str to avoid namespace conflicts. Use Str:: methods or global str_* helpers in any PHP project, including Laravel apps.
Pros:
Illuminate\Support\Str functionality, providing a drop-in replacement for string manipulation utilities (e.g., Str::slug(), Str::camel_case(), Str::snake_case()).IlluminateAgnostic\Str) prevents conflicts with Laravel’s built-in Str class, making it ideal for non-Laravel PHP projects or Laravel apps requiring customization.voku/portable-ascii for ASCII conversion).Cons:
Illuminate\Support suite.Str via facade aliasing or explicit namespace resolution.Str-like helpers.IlluminateAgnostic\Str namespace, but require explicit imports (e.g., use IlluminateAgnostic\Str\Support\Str).Str evolves (e.g., PHP 8+ features). Fork or patch if critical methods are missing.Str?
Str::of() return types).Str methods?
Str::macro() or third-party string packages (e.g., spatie/array-to-xml).Str-like functionality.mb_str_* or Str::of() directly).str_replace, ucfirst, custom helpers).Str (e.g., Str::title(), Str::ascii()).composer require pragmarx/ia-str.Str::slug()) and test.IlluminateAgnostic\Str.ia-str methods.| Scenario | Compatibility | Mitigation |
|---|---|---|
| Laravel 5.x–10.x | High (namespace isolation) | Use IlluminateAgnostic\Str explicitly. |
| PHP 7.0–7.3 | Native | Upgrade PHP or use polyfills. |
| PHP 8.x+ | Partial (test missing features) | Fork/patch or use Laravel’s native Str. |
| Non-Laravel projects | Full | No conflicts. |
| Custom string macros | Low (no Str::macro() support) |
Extend via traits or wrapper classes. |
Str::lower(), Str::contains()).Str::of()->slug()->prepend()).ia-str.Str features.voku/portable-ascii).composer.json (e.g., ^5.6.3) to avoid surprises.Str tests as a reference.strict_types=0 or patch the package.| Support Area | Effort | Tools |
|---|---|---|
| Basic string ops | Low | Laravel docs + ia-str tests. |
| Edge cases (Unicode) | Medium | Manual testing + voku/portable-ascii. |
| PHP 8+ compatibility | High | Fork/patch or use Laravel’s Str. |
| Custom extensions | Medium | Traits or wrapper classes. |
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Namespace collision in Laravel | High (if not isolated) | Use IlluminateAgnostic\Str explicitly. |
Missing Laravel Str method |
Medium | Implement custom logic or fork. |
| PHP version incompatibility | High | Pin PHP version or use polyfills. |
| Unicode/locale-specific bugs | Low | Test with mb_* functions as fallback. |
| Abandonware (no updates) | Medium | Fork or migrate to Laravel’s native Str. |
ia-str vs. Laravel’s Str.Str::of()->snake()->upper()).How can I help you explore Laravel packages today?