PHPackages                             web-fu/php-dot-notation - 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. web-fu/php-dot-notation

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

web-fu/php-dot-notation
=======================

Library that allows to access array and object with strong type support in Dot Notation

v2.1.0(1mo ago)35.2k—0%MITPHPPHP 8.0.\* || 8.1.\* || 8.2.\* || 8.3.\* || 8.4.\*

Since May 3Pushed 1mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (8)Versions (16)Used By (0)

PHP Dot Notation
================

[](#php-dot-notation)

[![Latest Stable Version](https://camo.githubusercontent.com/fc00a8ceebbd0fe06ccc9327ad5174523d6e4788c57b4d09cf1b944e8b30141d/68747470733a2f2f706f7365722e707567782e6f72672f7765622d66752f7068702d646f742d6e6f746174696f6e2f76)](https://packagist.org/packages/web-fu/php-dot-notation)[![PHP Version Require](https://camo.githubusercontent.com/d3fad4d629a36ecaf97fa2ec34ac1956a70ccb19ae34188c2d98bfa649e133fa/68747470733a2f2f706f7365722e707567782e6f72672f7765622d66752f7068702d646f742d6e6f746174696f6e2f726571756972652f706870)](https://packagist.org/packages/web-fu/php-dot-notation)[![Test status](https://github.com/web-fu/php-dot-notation/actions/workflows/tests.yaml/badge.svg)](https://github.com/web-fu/php-dot-notation/actions/workflows/tests.yaml/badge.svg)[![Static analysis status](https://github.com/web-fu/php-dot-notation/actions/workflows/static-analysis.yml/badge.svg)](https://github.com/web-fu/php-dot-notation/actions/workflows/static-analysis.yml/badge.svg)[![Code style status](https://github.com/web-fu/php-dot-notation/actions/workflows/code-style.yaml/badge.svg)](https://github.com/web-fu/php-dot-notation/actions/workflows/code-style.yaml/badge.svg)

### A library that allows to access objects and arrays using Dot Notation

[](#a-library-that-allows-to-access-objects-and-arrays-using-dot-notation)

This library allows to access objects and arrays using dot notation.

It also allows getting, setting, and creation of objects and arrays using dot notation.

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

[](#installation)

```
composer require web-fu/php-dot-notation
```

Getting and setting values
--------------------------

[](#getting-and-setting-values)

```
$array = [
    'foo' => [
        'bar' => 'test',
    ],
];

// Accessing an array
$dot = new Dot($array);
echo $dot->get('foo.bar'); //test

// Setting a value in an array
$dot->set('foo.bar', 'baz');
echo $array['foo']['bar']; //baz

// Accessing an object
$class = new class() {
    public string $property = 'test';

    public function method(): string
    {
        return 'foo';
    }
};

$dot = new Dot($class);
echo $dot->get('property'); //test
echo $dot->get('method()'); //foo

// Setting a value in an object
$dot->set('property', 'baz');
echo $class->property; //baz
```

Creating a new path
-------------------

[](#creating-a-new-path)

```
$array = [];
$dot = new Dot($array);
$dot->create('foo.baz', 'test');
echo $array['foo']['baz']; // test
echo PHP_EOL;

$class = new stdClass();
$dot = new Dot($class);
$dot->create('foo', 'test');
echo $class->foo; // test
echo PHP_EOL;
```

Unsetting a value in an array or an object
------------------------------------------

[](#unsetting-a-value-in-an-array-or-an-object)

```
$test = new class {
    public array $array = [
        'foo' => 'bar',
    ];
};

$dot = new Dot($test);
$dot->unset('array.foo');

var_dump(array_key_exists('foo', $test->array)); // false
```

> **Note**: The `init` method check if the path exits before trying to initialize it.
>
> The `create` method creates the path if it does not exist, if possible.

Converting from and to Dot Notation
-----------------------------------

[](#converting-from-and-to-dot-notation)

```
// Turning an object or an array into the dotified version of it
$array = [
    'foo' => [
        'bar' => 'test',
    ],
];
$dotified = Dot::dotify($array);

echo $dotified['foo.bar']; //test

// Turning a dotified array into a normal array
$normal = Dot::undotify($dotified);

echo $normal['foo']['bar']; //test
```

See `/examples` folder for full examples

Limitations And Warnings
------------------------

[](#limitations-and-warnings)

This tool have some limitations:

### Getting a method executes the method

[](#getting-a-method-executes-the-method)

```
$class = new class() {
    public function iDoSomething(): int
    {
        echo 'I Do Something ';
        return 0;
    }
}

$dot = new Dot($class);
echo $dot->get('iDoSomething()'); // I Do Something 0
```

### It's not possible to access private or protected properties

[](#its-not-possible-to-access-private-or-protected-properties)

This is a design decision to avoid breaking encapsulation.

```
$class = new class() {
    private string $property = 'test';
};

$dot = new Dot($class);
echo $dot->get('property'); //Unhandled Exception: WebFu\DotNotation\Exception\PathNotFoundException Path `property` not found
```

### It's not possible to discern if a method returns NULL or does not return at all

[](#its-not-possible-to-discern-if-a-method-returns-null-or-does-not-return-at-all)

This is a limitation of PHP

```
$class = new class() {
    public function thisMethodReturnsNull(): int|null
    {
        return null;
    }
    public function thisMethodDoesNotReturn(): void
    {
        //do something
    }
};

$dot = new Dot($class);
var_dump($dot->get('thisMethodReturnsNull()')); //NULL
var_dump($dot->get('thisMethodDoesNotReturn()')); //NULL
```

### It's not possible setting a method

[](#its-not-possible-setting-a-method)

```
$class = new class() {
    public function method(): int {
        return 0;
    }
};

$dot = new Dot($class);
$dot->set('method()', 20); //Unhandled Exception: WebFu\Proxy\UnsupportedOperationException Cannot set a class method
```

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance89

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~69 days

Recently: every ~138 days

Total

11

Last Release

54d ago

Major Versions

v1.7.0 → v2.0.02025-01-28

v1.7.1 → v2.1.02026-03-26

PHP version history (2 changes)v1.0.0PHP 8.0.\* || 8.1.\* || 8.2.\* || 8.3.\*

v2.0.0PHP 8.0.\* || 8.1.\* || 8.2.\* || 8.3.\* || 8.4.\*

### Community

Maintainers

![](https://www.gravatar.com/avatar/67ea52e8c69cddde94034b5d9006666d238a7b4266791954f5ce80e7264b722b?d=identicon)[web-fu](/maintainers/web-fu)

---

Top Contributors

[![web-fu](https://avatars.githubusercontent.com/u/2857138?v=4)](https://github.com/web-fu "web-fu (124 commits)")

---

Tags

phparrayobjectphp8dot notation

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/web-fu-php-dot-notation/health.svg)

```
[![Health](https://phpackages.com/badges/web-fu-php-dot-notation/health.svg)](https://phpackages.com/packages/web-fu-php-dot-notation)
```

###  Alternatives

[pharaonic/php-dot-array

Access array data quickly/easily using dot-notation and asterisk.

1011.6k3](/packages/pharaonic-php-dot-array)

PHPackages © 2026

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