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

Array Laravel Package

minwork/array

Minwork Array provides fast, well-tested helpers for nested, associative, and object arrays. Get/set/has plus map, filter, find, group, sort, and validation, with fluent-style chaining. No dependencies; modern PHP syntax.

View on GitHub
Deep Wiki
Context7

Pack of advanced PHP array functions

Frequently asked questions about Array
Does **minwork/array** work with Laravel 10 and PHP 8.2+? I’m worried about breaking changes.
The package was last updated in 2020 and hasn’t been tested against PHP 8.2 or Laravel 10. While core array methods may still function, you risk issues with strict typing, named arguments, or Laravel’s newer features. Test thoroughly in a staging environment before production use.
How do I avoid conflicts with Laravel’s built-in `Arr` helper when using `minwork/array`?
The package uses `Arr` as a global function/class, which conflicts with Laravel’s `Arr` helper. Rename the package’s alias in Composer (e.g., `MinworkArr`) or explicitly namespace it (e.g., `\Minwork\Array\Arr`) to prevent collisions. Check your autoloader for conflicts.
Can I chain methods like Laravel’s `Collection` (e.g., `Arr::set()->get()`)?
Yes, the package supports fluent chaining for methods like `set()`, `get()`, `map()`, and `filter()`. For example: `Arr::set($array, 'key')->map(fn($v) => $v * 2)->get()`. This mimics Laravel’s `Collection` style but works with plain arrays and objects.
What are the performance implications compared to Laravel’s `Arr` or native PHP arrays?
The package is optimized for PHP 7+ and offers comparable speed to Laravel’s `Arr` helper for basic operations. However, complex transformations (e.g., `mapObjects`, `group`) may introduce slight overhead. Benchmark against native PHP or `Collection` for your specific use case.
How do I handle arrays of Eloquent models or objects with this package?
The package includes object-specific methods like `mapObjects()`, `groupObjects()`, and `sortObjects()` to work with Eloquent models or arrays of objects. For example: `Arr::mapObjects($models, fn($model) => $model->name)`. It’s ideal for transforming API responses or form data.
Is there a way to integrate this with Laravel’s `Collection` class for seamless use?
No native integration exists, but you can manually bridge it by wrapping results in a `Collection` or creating static methods to pipe data. For example: `collect(Arr::filter($array))->toJson()`. Alternatively, extend Laravel’s `Arr` helper with this package’s methods if needed.
What alternatives exist for array manipulation in Laravel, and why choose this package?
Alternatives include Laravel’s built-in `Arr` helper, `spatie/array-to-object`, or custom implementations. Choose **minwork/array** for its expressive syntax (e.g., dot-notation), object support, and fluent chaining—ideal if you need more than Laravel’s `Arr` but want zero dependencies.
How do I validate nested arrays or objects using this package?
Use the `check()` method with custom callbacks or predefined validators. For example: `Arr::check($array, 'key1.key2', 'string')` or `Arr::check($array, fn($value) => strlen($value) > 5)`. It supports both dot-notation paths and direct callbacks.
Are there any security concerns with using this package in production?
The package has no known vulnerabilities, but its lack of recent updates means no security patches are applied. Monitor for PHP/Laravel deprecations (e.g., `create_function`) and consider forking if critical issues arise. Always validate user input before passing it to array methods.
Can I use this package for API payload transformations in Laravel?
Absolutely. The package excels at transforming nested API responses, filtering Eloquent collections, or restructuring form data. For example: `Arr::set($request->all(), 'user.address.city', $request->city)->toArray()`. Combine it with Laravel’s `Response` helpers for clean API outputs.
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.
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament