Stringable, ensuring API parity with Str::of(). This eliminates refactoring costs for teams already using Laravel’s string utilities, making it a zero-learning-curve upgrade for string manipulation tasks.Str helper suffices or where NLP/advanced text processing is needed (e.g., sentiment analysis).Stringable class natively.Str helper exactly (e.g., ->slug(), ->plural()), enabling drop-in replacement with minimal code changes. Example:
// Laravel
Str::of('hello world')->slug(); // "hello-world"
// Hyperf Stringable
Str::of('hello world')->slug(); // Identical output
symfony/string. Assess whether this is a blocker for your use cases.Why Adopt Over Laravel’s Native Stringable?
->ascii())?Adoption Strategy:
Str globally, or complement it for specific modules (e.g., APIs)?Str helpers are used?Long-Term Viability:
Stringable in future versions, making this package redundant?Testing and Validation:
Stringable for critical paths (e.g., bulk slug generation)?composer require hyperf/stringable
No framework-specific configuration is needed. The package auto-registers with Laravel’s service container.Str::of() methods.Illuminate\Support\Stringable.Phase 1: Evaluation (1–2 Weeks)
Stringable for:
->slug(), ->plural()).Str::of() methods work identically in Laravel.Phase 2: Pilot (2–4 Weeks)
Str::of() in non-critical modules (e.g., logging, validation helpers).// In AppServiceProvider
Str::macro('of', function ($value) {
return new \Hyperf\Stringable\Stringable($value);
});
Phase 3: Full Rollout (4–8 Weeks)
Str::of() usages to the new package.#[Deprecation('Use Hyperf\Stringable\Str::of() instead')]
function oldStrMethod() { ... }
Str helper references in internal docs.composer validate --strict
->as() vs. ->toString()).Str facade collisions).Str::of() in older, less-tested code after validating the new package’s stability.->headline()), implement a custom macro before full adoption:
Str::macro('headline', fn ($length = 140) => fn ($value) => ...);
Stringable).Str (e.g., "Hyperf’s Stringable lacks ->limit() but adds ->ascii()").->slug(), ->plural(), ->contains()).Str).laravel-debugbar or Xdebug.laravel-debugbar or spatie/laravel-query-log to measure:
How can I help you explore Laravel packages today?