PHPackages                             dflydev/dot-access-data - 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. dflydev/dot-access-data

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

dflydev/dot-access-data
=======================

Given a deep data structure, access data by dot notation.

v3.0.3(1y ago)720359.1M—3.6%19[5 issues](https://github.com/dflydev/dflydev-dot-access-data/issues)[1 PRs](https://github.com/dflydev/dflydev-dot-access-data/pulls)20MITPHPPHP ^7.1 || ^8.0CI failing

Since Jul 17Pushed 1y ago8 watchersCompare

[ Source](https://github.com/dflydev/dflydev-dot-access-data)[ Packagist](https://packagist.org/packages/dflydev/dot-access-data)[ Docs](https://github.com/dflydev/dflydev-dot-access-data)[ RSS](/packages/dflydev-dot-access-data/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (5)Versions (9)Used By (20)

Dot Access Data
===============

[](#dot-access-data)

[![Latest Version](https://camo.githubusercontent.com/5a05e2ec2d05a5090294bc4df0757de8122c0736f716ee84915f5a30dcbf5c45/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64666c796465762f646f742d6163636573732d646174612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dflydev/dot-access-data)[![Total Downloads](https://camo.githubusercontent.com/6c9ccf07c9d2a289a839ccc8b7801de7be9370f9c3977346bcd9dfafebee0a70/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64666c796465762f646f742d6163636573732d646174612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dflydev/dot-access-data)[![Software License](https://camo.githubusercontent.com/c2bffd81d308ced1cc3b0d66fb0ed453ab478a5e17c988b780f9de986a390ee2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/76f5db52c956273d81784d6f52cd7f810add6dd34b7275bd1a67c603c1d44fc7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f64666c796465762f64666c796465762d646f742d6163636573732d646174612f54657374732f6d61696e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/dflydev/dflydev-dot-access-data/actions?query=workflow%3ATests+branch%3Amain)[![Coverage Status](https://camo.githubusercontent.com/7bde8d4306373a56098296828bed1625bb03deda76199036de50c89a16cfaf1d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f64666c796465762f64666c796465762d646f742d6163636573732d646174612e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/dflydev/dflydev-dot-access-data/code-structure/)[![Quality Score](https://camo.githubusercontent.com/ff6624a3f838a56a64a1cba7633b2fc99f097a43bf488944d0f901fa3ef62394/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f64666c796465762f64666c796465762d646f742d6163636573732d646174612e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/dflydev/dflydev-dot-access-data)

Given a deep data structure, access data by dot notation.

Requirements
------------

[](#requirements)

- PHP (7.1+)

> For PHP (5.3+) please refer to version `1.0`.

Usage
-----

[](#usage)

Abstract example:

```
use Dflydev\DotAccessData\Data;

$data = new Data;

$data->set('a.b.c', 'C');
$data->set('a.b.d', 'D1');
$data->append('a.b.d', 'D2');
$data->set('a.b.e', ['E0', 'E1', 'E2']);

// C
$data->get('a.b.c');

// ['D1', 'D2']
$data->get('a.b.d');

// ['E0', 'E1', 'E2']
$data->get('a.b.e');

// true
$data->has('a.b.c');

// false
$data->has('a.b.d.j');

// 'some-default-value'
$data->get('some.path.that.does.not.exist', 'some-default-value');

// throws a MissingPathException because no default was given
$data->get('some.path.that.does.not.exist');
```

A more concrete example:

```
use Dflydev\DotAccessData\Data;

$data = new Data([
    'hosts' => [
        'hewey' => [
            'username' => 'hman',
            'password' => 'HPASS',
            'roles'    => ['web'],
        ],
        'dewey' => [
            'username' => 'dman',
            'password' => 'D---S',
            'roles'    => ['web', 'db'],
            'nick'     => 'dewey dman',
        ],
        'lewey' => [
            'username' => 'lman',
            'password' => 'LP@$$',
            'roles'    => ['db'],
        ],
    ],
]);

// hman
$username = $data->get('hosts.hewey.username');
// HPASS
$password = $data->get('hosts.hewey.password');
// ['web']
$roles = $data->get('hosts.hewey.roles');
// dewey dman
$nick = $data->get('hosts.dewey.nick');
// Unknown
$nick = $data->get('hosts.lewey.nick', 'Unknown');

// DataInterface instance
$dewey = $data->getData('hosts.dewey');
// dman
$username = $dewey->get('username');
// D---S
$password = $dewey->get('password');
// ['web', 'db']
$roles = $dewey->get('roles');

// No more lewey
$data->remove('hosts.lewey');

// Add DB to hewey's roles
$data->append('hosts.hewey.roles', 'db');

$data->set('hosts.april', [
    'username' => 'aman',
    'password' => '@---S',
    'roles'    => ['web'],
]);

// Check if a key exists (true to this case)
$hasKey = $data->has('hosts.dewey.username');
```

`Data` may be used as an array, since it implements `ArrayAccess` interface:

```
// Get
$data->get('name') === $data['name']; // true

$data['name'] = 'Dewey';
// is equivalent to
$data->set($name, 'Dewey');

isset($data['name']) === $data->has('name');

// Remove key
unset($data['name']);
```

`/` can also be used as a path delimiter:

```
$data->set('a/b/c', 'd');
echo $data->get('a/b/c'); // "d"

$data->get('a/b/c') === $data->get('a.b.c'); // true
```

License
-------

[](#license)

This library is licensed under the MIT License - see the LICENSE file for details.

Community
---------

[](#community)

If you have questions or want to help out, join us in the #dflydev channel on irc.freenode.net.

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity76

Solid adoption and visibility

Community39

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~624 days

Recently: every ~597 days

Total

8

Last Release

679d ago

Major Versions

v1.1.0 → v2.0.02017-12-21

v2.0.0 → v3.0.02021-01-01

PHP version history (3 changes)v1.0.0PHP &gt;=5.3.2

v2.0.0PHP ^7.0

v3.0.0PHP ^7.1 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/0d6029bd16a0e8a9b97358a75b54affa6baadc1d9b0ca7eab2b6dd6c681ad7a8?d=identicon)[simensen](/maintainers/simensen)

---

Top Contributors

[![colinodell](https://avatars.githubusercontent.com/u/202034?v=4)](https://github.com/colinodell "colinodell (47 commits)")[![simensen](https://avatars.githubusercontent.com/u/191200?v=4)](https://github.com/simensen "simensen (43 commits)")[![eggnaube](https://avatars.githubusercontent.com/u/1303328?v=4)](https://github.com/eggnaube "eggnaube (2 commits)")[![driesvints](https://avatars.githubusercontent.com/u/594614?v=4)](https://github.com/driesvints "driesvints (1 commits)")[![grasmash](https://avatars.githubusercontent.com/u/539205?v=4)](https://github.com/grasmash "grasmash (1 commits)")[![madflow](https://avatars.githubusercontent.com/u/183248?v=4)](https://github.com/madflow "madflow (1 commits)")[![martinssipenko](https://avatars.githubusercontent.com/u/598744?v=4)](https://github.com/martinssipenko "martinssipenko (1 commits)")[![mikeryan776](https://avatars.githubusercontent.com/u/616491?v=4)](https://github.com/mikeryan776 "mikeryan776 (1 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")[![ArnaudLigny](https://avatars.githubusercontent.com/u/80580?v=4)](https://github.com/ArnaudLigny "ArnaudLigny (1 commits)")[![smnandre](https://avatars.githubusercontent.com/u/1359581?v=4)](https://github.com/smnandre "smnandre (1 commits)")[![cfrutos](https://avatars.githubusercontent.com/u/6273450?v=4)](https://github.com/cfrutos "cfrutos (1 commits)")[![dhrrgn](https://avatars.githubusercontent.com/u/149921?v=4)](https://github.com/dhrrgn "dhrrgn (1 commits)")

---

Tags

dotdataaccessnotation

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dflydev-dot-access-data/health.svg)

```
[![Health](https://phpackages.com/badges/dflydev-dot-access-data/health.svg)](https://phpackages.com/packages/dflydev-dot-access-data)
```

###  Alternatives

[fakerphp/faker

Faker is a PHP library that generates fake data for you.

4.0k358.5M3.5k](/packages/fakerphp-faker)[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k295.3M2.5k](/packages/symfony-property-access)[league/config

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

564302.2M24](/packages/league-config)[mbezhanov/faker-provider-collection

A collection of custom providers for the Faker library

2138.6M24](/packages/mbezhanov-faker-provider-collection)[php-units-of-measure/php-units-of-measure

A PHP library for converting between standard units of measure.

3123.4M20](/packages/php-units-of-measure-php-units-of-measure)[amenadiel/jpgraph

Composer Friendly, full refactor of JpGraph, library to make graphs and charts

1492.2M7](/packages/amenadiel-jpgraph)

PHPackages © 2026

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