renoki-co/laravel-explicit-array

Improved Laravel dot notation for explicit array keys.
1,014 9
Install
composer require renoki-co/laravel-explicit-array
Latest Version:1.0.0
License:Apache-2.0
Last Updated:Feb 9, 2026
Links: GitHub  ·  Packagist
Maintainer: rennokki

Laravel Explicit Array

CI codecov StyleCI Latest Stable Version Total Downloads Monthly Downloads License

Improved Laravel dot notation for explicit array keys.

🚀 Installation

You can install the package via composer:

composer require renoki-co/laravel-explicit-array

🙌 Usage

The original Laravel's Arr::set() method treats the dots within the key as separators for nested values. This is expected. The segments will create a nested value some -> annotation -> com/ttl with a value of 1800.

$annotations = [
    'some.annotation.com/ttl' => 900,
];

Arr::set($annotations, 'some.annotation.com/ttl', 1800);

// Current result
// [
//     'some' => [
//         'annotation' => [
//             'com/ttl' => 1800
//         ]
//     ]
// ]

// Desired result
// [
//     'some.annotation.com/ttl' => 1800
// ]

To fix this, Explicit Array introduces a new RenokiCo\ExplicitArray\Arr class, which altered the ::set() method, so that will make sure to read the segments between quotes as literal keys.

You may use this class as your regular Arr class because it extends the original \Illuminate\Support\Arr class.

use RenokiCo\ExplicitArray\Arr;

Arr::set($annotations, '"some.annotation.com/ttl"', 1800);

// [
//     'some.annotation.com/ttl' => 1800
// ]

This can work with mixed segments, meaning that as long as you keep the dots outside the quotes, you can specify nested values:

use RenokiCo\ExplicitArray\Arr;

Arr::set($annotations, 'annotations.nested."some.annotation.com/ttl"', 1800);

// [
//     'annotations' => [
//         'nested' => [
//             'some.annotation.com/ttl' => 1800
//         ]
//     ]
// ]

🐛 Testing

vendor/bin/phpunit

🤝 Contributing

Please see CONTRIBUTING for details.

🔒 Security

If you discover any security related issues, please email alex@renoki.org instead of using the issue tracker.

🎉 Credits

Related Packages

ishworkh/multi-level-array-iterator

Provides a way to loop through nested arrays with any depth

8,735 0
pragmarx/ia-arr

Laravel Illuminate Agnostic Arr

3,743,694 54
iolson/support

Opinionated Laravel Support Package

1,520 3
dukhanin/laravel-support

Laravel 5 additionall support package

267 0
aimeos/map

Easy and elegant handling of PHP arrays as array-like collection objects similar...

504,915 4,324