Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Stringy Laravel Package

voku/stringy

voku/stringy is a PHP string manipulation library with a fluent, chainable API and multibyte/Unicode-safe helpers. It offers common text utilities like trimming, casing, slugging, replacing, and comparisons, aiming for predictable results across encodings.

View on GitHub
Deep Wiki
Context7

A string manipulation library with multibyte support

Frequently asked questions about Stringy
How does voku/stringy improve Laravel’s native Str:: helper for multibyte strings?
voku/stringy provides robust UTF-8/multibyte support where Laravel’s Str:: helper falls short. For example, `Stringy::create($text)->trim()` handles non-ASCII characters (like emojis or CJK text) more reliably than PHP’s native `trim()`, reducing edge-case bugs in internationalized applications.
Can I use voku/stringy in Laravel without a facade or service provider?
Yes, the package is dependency-free and can be used directly via `Stringy::create($string)->method()`. For convenience, manually register a facade in `config/app.php` or use a helper class (e.g., `app()->make(StringHelper::class)`) to wrap the API in a Laravel-friendly way.
What Laravel versions and PHP versions does voku/stringy support?
voku/stringy supports PHP 8.0+ and is compatible with Laravel 9/10 (LTS versions). It aligns with Laravel’s modern PHP requirements, ensuring no version conflicts in your dependency graph.
How do I benchmark voku/stringy against Laravel’s Str:: for performance?
Use a simple script to compare execution time for critical operations (e.g., `Stringy::create($text)->slugify()` vs. `Str::slug($text)`). Stringy’s optimizations may outperform Str:: for multibyte-heavy workloads, but test with your specific dataset—especially for bulk processing like 10K+ slug conversions.
Does voku/stringy replace Laravel’s Str:: helper entirely, or should I use both?
Use both strategically: leverage Stringy for multibyte-sensitive operations (e.g., trimming, replacing, or normalizing international text) and Str:: for simplicity in ASCII-heavy contexts. Document your team’s convention (e.g., ‘Use Stringy for X, Str:: for Y’) to avoid confusion.
How can I test multibyte edge cases (e.g., emojis, CJK characters) with voku/stringy?
Write unit tests with Unicode characters like `‘😊’`, `‘你好’`, or `‘é’` to verify methods like `trim()`, `replace()`, and `slugify()`. Use PHPUnit assertions to check output consistency, especially for normalization (NFC/NFD) and grapheme clusters.
Is voku/stringy safe for production use in Laravel APIs or queues?
Yes, Stringy is stateless and thread-safe, making it ideal for Laravel queues/jobs or API request/response normalization. Its lightweight design (~1.5MB) ensures minimal overhead, even in high-traffic applications.
What are the alternatives to voku/stringy for string manipulation in Laravel?
Laravel’s built-in `Str::` helper is sufficient for basic ASCII operations, while Symfony’s `StringUtils` offers more features but adds bloat. Stringy strikes a balance: lightweight, multibyte-optimized, and chainable—perfect for global apps where Str:: lacks precision.
How do I migrate from Laravel’s Str:: to voku/stringy incrementally?
Start by replacing 2–3 Str:: methods (e.g., `Str::slug()` → `Stringy::create()->slugify()`) in a single file, then use IDE refactoring tools (e.g., PHPStorm’s ‘Replace in Path’) to update calls gradually. Test each change with multibyte inputs to catch regressions early.
Does voku/stringy support Laravel’s Blade templates or livewire components?
Yes, you can use Stringy in Blade templates or Livewire by instantiating it directly (e.g., `@php $slug = Stringy::create($title)->slugify() @endphp`). For Livewire, pass Stringy-processed data to properties or emit events with normalized text. Avoid registering it globally to keep memory usage low.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor