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

Utilities Laravel Package

joomla/utilities

Joomla Utilities provides lightweight helper classes for common tasks, including ArrayHelper methods to cast arrays to integers, convert arrays to objects/strings, and extract arrays from objects—handy utilities for PHP apps and Joomla Framework projects.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by installing the package via Composer (composer require joomla/utilities) and familiarize yourself with ArrayHelper, the core utility for common array/object transformations. Begin with practical use cases like sanitizing request input using toInteger(), extracting column values with getColumn(), or converting nested arrays to flat key-value pairs with flatten(). These are the most frequently used helpers in day-to-day Laravel development—especially for data normalization before validation or database operations.

Implementation Patterns

  • Request Sanitization: Use ArrayHelper::toInteger() on request inputs (e.g., query params or form data) to safely coerce strings like "123abc" to integers.
  • API Response Normalization: Convert Eloquent collections or arrays to objects (e.g., DTOs) using toObject() for type consistency.
  • Data Aggregation: Use pivot() to reindex query results by a key (e.g., grouping products by category_id) for efficient rendering in Blade templates.
  • Validation Prep: Flatten request arrays (with flatten()) when validating dot-notation inputs against nested rules, then restructure with ArrayHelper::getColumn() to extract only validated fields.
  • Configuration Munging: Use isAssociative() to distinguish between list and key-value configs before applying logic (e.g., for CLI flag parsing or environment variable loading).
  • Regex Abstraction: Replace complex string patterns with RegEx::oneOrMore(), optional(), and capture() to build readable, maintainable regex chains (e.g., for URL parsing or slug validation).

Gotchas and Tips

  • Type Safety in v3+: All methods enforce stricter types (PHP 8.1+), so ArrayHelper::getValue() now requires $type as a string—pass explicit types like 'integer' or 'boolean' instead of relying on defaults.
  • toObject() Pitfall: It creates stdClass by default; if passing a custom class name, ensure properties match input structure or use reflection-friendly DTOs to avoid null-fill.
  • arrayUnique() Deepness: Only compares top-level array entries for identity—use array_map('serialize', $array) + unserialize() workaround if needing deep uniqueness.
  • flatten() Keys: Dot-separated keys (default) are Laravel-friendly but avoid conflicts if your data contains dots—use a custom separator (e.g., .::).
  • RegEx::match() Returns Only Captured Groups: Unmarked expressions won’t appear in results—always wrap key parts in RegEx::capture().
  • Maturity Warning: Despite recent releases (2025), low dependents/stars suggest limited Laravel adoption—test edge cases thoroughly, and prefer native Laravel helpers where possible (e.g., collect()->map() for simple transformations).
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
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
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests