PHPackages                             prowebcraft/dot - 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. prowebcraft/dot

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

prowebcraft/dot
===============

PHP dot notation array access

0.1.0(8y ago)529.6k↓45.5%3MITPHPPHP &gt;=5.4CI failing

Since Feb 15Pushed 4y ago4 watchersCompare

[ Source](https://github.com/prowebcraft/dot)[ Packagist](https://packagist.org/packages/prowebcraft/dot)[ Docs](https://github.com/prowebcraft/php-dot-notation)[ RSS](/packages/prowebcraft-dot/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (3)

Dot - PHP dot notation array access
===================================

[](#dot---php-dot-notation-array-access)

Based on [adbario/php-dot-notation](https://github.com/adbario/php-dot-notation) package

Easy access to multidimensional arrays with dot notation. With dot notation, your code is cleaner and handling deeper arrays is super easy.

This class implements PHP's ArrayAccess class, so Dot object can also be used the same way as normal arrays with additional dot notation.

With Dot you can change this:

```
echo $data['info']['home']['address'];
```

to this:

```
echo $data->get('info.home.address');
```

or even this:

```
echo $data['info.home.address'];
```

Installation
------------

[](#installation)

Via composer:

```
composer require prowebcraft/dot

```

Or just copy the class file Dot.php and handle namespace yourself.

#### With [Composer](https://getcomposer.org/):

[](#with-composer)

```
composer require prowebcraft/dot

```

#### Manual installation:

[](#manual-installation)

1. Download the latest release
2. Extract the files into your project
3. require\_once '/path/to/dot/src/Dot.php';

Usage
-----

[](#usage)

This array will be used as a reference on this guide:

```
$array = [
    'user' => [
        'firstname' => 'John',
        'lastname'  => 'Smith'
    ],
    'info' => [
        'kids' => [
            0 => 'Laura',
            1 => 'Chris',
            2 => 'Little Johnny'
        ],
        'home' => [
            'address' => 'Rocky Road 3'
        ]
    ]
];
```

### Create a Dot object

[](#create-a-dot-object)

To start with an empty array, just create a new Dot object:

```
$data = new \Prowebcraft\Dot;
```

If you have an array already available, inject it to the Dot object:

```
$data = new \Prowebcraft\Dot($array);
```

Set an array after creating the Dot object:

```
$data->setArray($array);
```

Set an array as a reference, and all changes will be made directly to the original array:

```
$data->setReference($array);
```

### Set a value

[](#set-a-value)

Set i.e. a phone number in the 'home' array:

```
$data->set('info.home.tel', '09-123-456-789');

// Array style
$data['info.home.tel'] = '09-123-456-789';
```

Set multiple values at once:

```
$data->set([
    'user.haircolor'    => 'blue',
    'info.home.address' => 'Private Lane 1'
]);
```

If the value already exists, Dot will override it with a new value.

### Get a value

[](#get-a-value)

```
echo $data->get('info.home.address');

// Default value if the path doesn't exist
echo $data->get('info.home.country', 'some default value');

// Array style
echo $data['info.home.address'];
```

Get all the stored values:

```
$values = $data->all();
``

Get a value from a path and remove it:

```php
$address = $data->pull('home.address');
```

Get all the stored values and remove them:

```
$values = $data->pull();
```

### Add a value

[](#add-a-value)

```
$data->add('info.kids', 'Amy');
```

Multiple values at once:

```
$data->add('info.kids', [
    'Ben', 'Claire'
]);
```

### Check if a value exists

[](#check-if-a-value-exists)

```
if ($data->has('info.home.address')) {
    // Do something...
}

// Array style
if (isset($data['info.home.address'])) {
    // Do something...
}
```

### Delete a value

[](#delete-a-value)

```
$data->delete('info.home.address');

// Array style
unset($data['info.home.address']);
```

Multiple values at once:

```
$data->delete([
    'user.lastname', 'info.home.address'
]);
```

### Clear values

[](#clear-values)

Delete all the values from a path:

```
$data->clear('info.home');
```

Clear multiple paths at once:

```
$data->clear([
    'user', 'info.home'
]);
```

Clear all data:

```
$data->clear();
```

### Sort the values

[](#sort-the-values)

You can sort the values of a given path or all the stored values.

Sort the values of a path:

```
$kids = $data->sort('info.kids');

// Sort recursively
$info = $data->sort('info');
```

Sort all the values

```
$sorted = $data->sort();

// Sort recursively
$sorted = $data->sort();
```

### Magic methods

[](#magic-methods)

Magic methods can be used to handle single level data (without dot notation). These examples are not using the same data array as examples above.

Set a value:

```
$data->name = 'John';
```

Get a value:

```
echo $data->name;
```

Check if a value exists:

```
if (isset($data->name)) {
    // Do something...
}
```

Delete a value:

```
unset($data->name);
```

License
-------

[](#license)

[MIT license](LICENSE.md)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

3014d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4133348?v=4)[Andrei Mistulov](/maintainers/prowebcraft)[@prowebcraft](https://github.com/prowebcraft)

---

Tags

phpArrayAccessdotnotation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/prowebcraft-dot/health.svg)

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

###  Alternatives

[adbario/php-dot-notation

PHP dot notation access to arrays

4638.8M182](/packages/adbario-php-dot-notation)[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

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