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

String Laravel Package

joomla/string

Joomla Framework String package for robust string handling in PHP. Installable via Composer, it provides utilities and helpers for common string operations and is maintained as part of the Joomla Framework ecosystem.

View on GitHub
Deep Wiki
Context7

Getting Started

Install via Composer: composer require joomla/string. The package provides StringHelper and Inflector classes for common string operations—ideal for lightweight, framework-agnostic utilities. Start by reviewing the src/ directory (especially StringHelper.php and Inflector.php) as official docs are minimal (currently TODO). Begin with basic tasks like cleaning user input:

use Joomla\String\StringHelper;

$title = StringHelper::clean('  My  Category  Title  '); // "My Category Title"

For pluralization/singularization:

use Joomla\String\Inflector;

$inflector = new Inflector();
$singular = $inflector->singular('categories'); // "category"

Implementation Patterns

  • Input sanitization: Use StringHelper::clean() for normalizing whitespace in titles, slugs, or search queries; StringHelper::truncate() and StringHelper::short() for preview summaries.
  • Inflection in domain logic: Leverage Inflector for generating pluralized route segments or DB table names in generic CRUD scaffolding (e.g., Inflector::plural('item')"items").
  • Strict dependency isolation: Integrate only where cross-platform compatibility is critical (e.g., shared console tools between Joomla/Laravel). Avoid replacing Laravel’s built-in Str::of()—this package adds little beyond native PHP + Doctrine Inflector.
  • Test-driven discovery: Since docs are sparse, inspect tests/ for usage examples and edge-case expectations (e.g., how truncate() handles multi-byte characters).

Gotchas and Tips

  • PHP version locked: v3.x requires PHP ≥8.1; v4.x (per changelog) requires PHP ≥8.3. Explicitly pin version in composer.json to avoid runtime failures from auto-updates.
  • Inflector limitations: Irregular plurals (e.g., "data""datum", "people""person") aren’t guaranteed—Doctrine Inflector’s rules apply. Add custom overrides via subclassing if needed.
  • No stable API surface: Last releases (3.0.4, 2025-07-23) fix packaging/CI, not features. Treat as stable only for basic clean/truncate—not future-proof for new functionality.
  • Debugging tips: If clean() or short() behaves unexpectedly, verify encoding (use mb_internal_encoding('UTF-8')); v4.x drops legacy phputf8 and relies solely on symfony/polyfill-mbstring.
  • Laravel-specific advice: Wrap Inflector in a service provider if used, but prefer Str::singular()/Str::plural() for consistency. This package adds maintenance cost without Laravel integration value.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4