PHPackages                             smoren/nested-accessor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. smoren/nested-accessor

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

smoren/nested-accessor
======================

Accessor for getting and setting values of nested data structures (arrays or objects)

v0.1.16(3y ago)101.1k32MITPHPPHP &gt;=7.4.0

Since Aug 28Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Smoren/nested-accessor-php)[ Packagist](https://packagist.org/packages/smoren/nested-accessor)[ RSS](/packages/smoren-nested-accessor/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (7)Versions (18)Used By (2)

nested-accessor
===============

[](#nested-accessor)

[![Packagist PHP Version Support](https://camo.githubusercontent.com/ea145bb1ed8e25464991ce414eb4e934a86d3144a0b174fd4a79427cbbb2a728/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736d6f72656e2f6e65737465642d6163636573736f72)](https://camo.githubusercontent.com/ea145bb1ed8e25464991ce414eb4e934a86d3144a0b174fd4a79427cbbb2a728/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736d6f72656e2f6e65737465642d6163636573736f72)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/35db02b69fcf4cf95be09a798efe72b2368fde7c3f3927dacc424056453fcfcd/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f536d6f72656e2f6e65737465642d6163636573736f722d7068702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Smoren/nested-accessor-php/?branch=master)[![Coverage Status](https://camo.githubusercontent.com/f100702ca4e38dce0f47b131b6ed41c183dd7d808837caf8895880ad31a80ca4/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f536d6f72656e2f6e65737465642d6163636573736f722d7068702f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/Smoren/nested-accessor-php?branch=master)[![Build and test](https://github.com/Smoren/nested-accessor-php/actions/workflows/test_master.yml/badge.svg)](https://github.com/Smoren/nested-accessor-php/actions/workflows/test_master.yml/badge.svg)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

Accessor for getting and setting values of nested data structures (arrays or objects).

### How to install to your project

[](#how-to-install-to-your-project)

```
composer require smoren/nested-accessor

```

### Unit testing

[](#unit-testing)

```
composer install
composer test-init
composer test

```

### Usage

[](#usage)

#### NestedAccessor

[](#nestedaccessor)

```
use Smoren\NestedAccessor\Components\NestedAccessor;

$source = [
    'data' => [
        'id' => 1,
        'name' => 'Countries classifier',
        'extra' => null,
        'country_names' => ['Russia', 'Belarus'],
    ],
    'countries' => [
        [
            'name' => 'Russia',
            'cities' => [
                [
                    'name' => 'Moscow',
                    'extra' => [
                        'codes' => [
                            ['value' => 7495],
                            ['value' => 7499],
                        ],
                    ],
                ],
                [
                    'name' => 'Petersburg',
                    'extra' => [
                        'codes' => [
                            ['value' => 7812],
                        ],
                    ],
                ],
            ],
        ],
        [
            'name' => 'Belarus',
            'cities' => [
                [
                    'name' => 'Minsk',
                    'extra' => [
                        'codes' => [
                            ['value' => 375017],
                        ],
                    ],
                ],
            ],
        ],
    ]
];

$accessor = new NestedAccessor($input);

echo $accessor->get('data.name'); // 'Countries classifier'
print_r($accessor->get('countries.name')); // ['Russia', 'Belarus']
print_r($accessor->get('countries.cities.name')); // ['Moscow', 'Petersburg', 'Minsk']
print_r($accessor->get('countries.cities.extra.codes.value')); // [7495, 7499, 7812, 375017]

var_dump($accessor->isset('data.name')); // true
var_dump($accessor->isset('data.extra')); // false
var_dump($accessor->isset('this.path.not.exist')); // false

var_dump($accessor->exist('data.name')); // true
var_dump($accessor->exist('data.extra')); // true
var_dump($accessor->exist('this.path.not.exist')); // false

$accessor->set('data.name', 'New name');
echo $accessor->get('data.name'); // 'New name'

$accessor->append('data.country_names', 'Mexico');
echo $accessor->get('data.country_names'); // ['Russia', 'Belarus', 'Mexico']

$accessor->delete('data.name');
var_dump($accessor->exist('data.name')); // false
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~17 days

Recently: every ~36 days

Total

17

Last Release

1116d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7403235?v=4)[Smoren](/maintainers/smoren)[@Smoren](https://github.com/Smoren)

---

Top Contributors

[![Smoren](https://avatars.githubusercontent.com/u/7403235?v=4)](https://github.com/Smoren "Smoren (24 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

accessornested-structuresphpphp-librarynestedaccessor

###  Code Quality

TestsCodeception

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/smoren-nested-accessor/health.svg)

```
[![Health](https://phpackages.com/badges/smoren-nested-accessor/health.svg)](https://phpackages.com/packages/smoren-nested-accessor)
```

###  Alternatives

[league/config

Define configuration arrays with strict schemas and access values with dot notation

565323.7M35](/packages/league-config)[yassi/nova-nested-form

A Laravel Nova package that allows you to create/update/delete nested related fields from a parent form.

239505.2k](/packages/yassi-nova-nested-form)[kartik-v/yii2-tree-manager

An enhanced tree management module with tree node selection and manipulation using nested sets.

151545.0k15](/packages/kartik-v-yii2-tree-manager)[michaels/data-manager

Simple data manager for nested data, dot notation array access, extendability, and container interoperability.

121.9k2](/packages/michaels-data-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
