Weave 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

Laravel Extend Collections Laravel Package

konsulting/laravel-extend-collections

Extends Laravel's Collection class with handy macros and helper methods for more expressive, concise array and collection transformations. A drop-in package for cleaner, more readable collection pipelines in Laravel applications.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Install the package with Composer and publish any config/service provider if the package exposes one (php artisan vendor:publish).
  • Look first at the fromDot helper and its relationship to Laravel’s Arr::undot(). That is the core behavior changed in 0.3.1.
  • A good first use case is normalizing flat, dot-keyed payloads — settings imports, env-style config maps, or form submissions using keys like mail.host — into nested arrays before validation or persistence.
$nested = fromDot([
    'mail.host' => 'smtp.example.com',
    'mail.port' => 587,
]);

Implementation Patterns

  • Use fromDot at the boundary where flat data enters your domain: request normalization, config importers, or settings loaders.
  • Validate the flat dot keys first, then convert. This keeps validation rules readable and avoids validating a deeply nested structure you just built.
  • Pair with Arr::dot() when you need round-tripping: flatten for storage or comparison, then fromDot back to nested form.
  • For mixed payloads, keep nested and flat data separate before conversion. The 0.3.1 fix reduces over-eager undotting, but explicit boundaries remain the safest pattern.
  • If you maintain custom normalizers or macros around the package, route them through fromDot rather than calling undot() directly so you inherit the package’s fixed behavior.

Gotchas and Tips

  • 0.3.1 is a patch release — no breaking changes expected. The fix addresses fromDot being “overzealous” with undot, meaning keys that should have remained literal dotted keys were being split unintentionally.
  • If you worked around the old behavior by pre-escaping or manually reconstructing arrays, re-test those paths after upgrading; the workaround may now double-process keys.
  • Debug by comparing before/after: Arr::dot($nested) should reproduce your original flat array when the data is purely dot-keyed.
  • Literal keys containing dots (e.g. a key that is genuinely foo.bar, not a nested path) are the main edge case to verify. Add a regression test if your application relies on them.
  • Extension points such as macros or custom normalizers should be checked after upgrading, since they may have depended on the previous overzealous conversion.
  • When in doubt, isolate fromDot calls and assert exact array shapes in tests rather than relying on assertArraySubset-style checks, which can hide key-splitting regressions.
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.
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
adachsoft/php-code-style