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.
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.
ArrayHelper::toInteger() on request inputs (e.g., query params or form data) to safely coerce strings like "123abc" to integers.toObject() for type consistency.pivot() to reindex query results by a key (e.g., grouping products by category_id) for efficient rendering in Blade templates.flatten()) when validating dot-notation inputs against nested rules, then restructure with ArrayHelper::getColumn() to extract only validated fields.isAssociative() to distinguish between list and key-value configs before applying logic (e.g., for CLI flag parsing or environment variable loading).RegEx::oneOrMore(), optional(), and capture() to build readable, maintainable regex chains (e.g., for URL parsing or slug validation).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().collect()->map() for simple transformations).How can I help you explore Laravel packages today?