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

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

gsteel/dot
==========

A Utility for retrieving typed values from nested arrays

1.9.0(7mo ago)3197.0k—3.3%[3 PRs](https://github.com/gsteel/dot/pulls)3MITPHPPHP ~8.2.0 || ~8.3 || ~8.4 || ~8.5CI passing

Since Feb 11Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/gsteel/dot)[ Packagist](https://packagist.org/packages/gsteel/dot)[ Docs](https://github.com/gsteel/dot)[ RSS](/packages/gsteel-dot/feed)WikiDiscussions 1.10.x Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (25)Used By (3)

Dot
===

[](#dot)

[![Continuous Integration](https://github.com/gsteel/dot/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/gsteel/dot/actions/workflows/continuous-integration.yml)[![codecov](https://camo.githubusercontent.com/71ba9d7c560f5877aede9bd8836a52f6651b1a1c748853808928e185705d31f9/68747470733a2f2f636f6465636f762e696f2f67682f67737465656c2f646f742f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d546a4c4b7535466b6a41)](https://codecov.io/gh/gsteel/dot)[![psalm coverage](https://camo.githubusercontent.com/0317ea9cd6fd2323f716a1cd5b0c1bf790d6db38bc646d24891211274d51fe7c/68747470733a2f2f73686570686572642e6465762f6769746875622f67737465656c2f646f742f636f7665726167652e737667)](https://shepherd.dev/github/gsteel/dot)[![psalm level](https://camo.githubusercontent.com/dd95d750b38f8e6b0d8f902d661fe72200197f5a9219df960d810cdd8f17c719/68747470733a2f2f73686570686572642e6465762f6769746875622f67737465656c2f646f742f6c6576656c2e737667)](https://shepherd.dev/github/gsteel/dot)

Retrieve strongly typed values from deeply nested arrays.

This library will not set any values or manipulate data structures in any way. It is purely a way to retrieve information.

Usage
-----

[](#usage)

### Give me a typed value or throw an exception

[](#give-me-a-typed-value-or-throw-an-exception)

```
use GSteel\Dot;
use GSteel\MissingKey;
use GSteel\InvalidValue;
use stdClass;

$data = [
    'data' => [
        'float' => 1.23,
        'integer' => 42,
        'bool' => true,
        'string' => 'Goats',
        'callable' => static fn (): string => 'Hey!',
        'instance' => new stdClass(),
        'mixed' => null,
        'array' => ['a' => 'b'],
    ],
];

$value = Dot::float('data.float', $data); // 1.23
$value = Dot::integer('data.integer', $data); // 42
$value = Dot::bool('data.bool', $data); // true
$value = Dot::string('data.string', $data); // Goats
$value = Dot::callable('data.callable', $data); // function
$value = Dot::instanceOf('data.instance', $data, stdClass::class); // object
$value = Dot::valueAt('data.mixed'); // mixed
$value = Dot::array('data.array'); // ['a' => 'b']

$value = Dot::string('nope.not-there', $data); // Exception: MissingKey
$value = Dot::string('data.float', $data); // Exception: InvalidValue
```

### Retrieve a typed value or null

[](#retrieve-a-typed-value-or-null)

All the methods have consistent names, so `floatOrNull`, `boolOrNull` etc.

```
use GSteel\Dot;

$data = ['a' => ['b' => ['c' => 'foo']]];

$value = Dot::stringOrNull('a.b.c', $data); // "foo"
$value = Dot::stringOrNull('a.b.nope', $data); // null
$value = Dot::integerOrNull('a.b.c', $data); // null
```

### Retrieve a typed existing value or fallback to a given default

[](#retrieve-a-typed-existing-value-or-fallback-to-a-given-default)

```
use GSteel\Dot;

$data = ['a' => ['b' => ['c' => 'foo']]];

$value = Dot::stringDefault('a.b.c', $data, 'bar'); // "foo"
$value = Dot::stringDefault('a.b.nope', $data, 'bar'); // "bar"
$value = Dot::integerDefault('a.b.c', $data, 42); // 42
```

### Dots in the array keys?

[](#dots-in-the-array-keys)

```
use GSteel\Dot;

$data = [
    'data' => [
        'dot.here' => 'value',
        'slash/dot.' => 'value',
        'array/' => [
            'd.o.t.s' => [
                'p|pes' => 'value',
            ],
        ],
    ],
];

$value = Dot::string('data/dot.here', $data, '/'); // "value"
$value = Dot::string('data|slash/dot.', $data, '|'); // "value"
$value = Dot::string('data*array/*d.o.t.s*p|pes', $data, '*'); // "value"
```

Why?
----

[](#why)

As a mostly happy [psalm](https://psalm.dev) user, it is **really boring** telling Psalm the configuration array you just retrieved from your DI container has a possibly null string value somewhere. For example:

```
use GSteel\Dot;

$config = $container->get('config');

$connectionParams = $config['doctrine']['connection']['params'] ?? [];
// 👆 Psalm has no idea what that is.

// Alternatively…

$params = [
    'host' => Dot::stringDefault('doctrine.connection.params.host', $config, 'localhost'),
    'port' => Dot::integerDefault('doctrine.connection.params.port', $config, 1234),
];
```

Hasn't this been done before?
-----------------------------

[](#hasnt-this-been-done-before)

Yes. Here's a few:

- [dflydev/dflydev-dot-access-data](https://github.com/dflydev/dflydev-dot-access-data)
- [adbario/php-dot-notation](https://github.com/adbario/php-dot-notation)
-

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance78

Regular maintenance activity

Popularity37

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 63.9% 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 ~79 days

Recently: every ~104 days

Total

20

Last Release

57d ago

PHP version history (8 changes)1.0.0PHP ~8.0 || ~8.1

1.2.0PHP ^7.3 || ~8.0 || ~8.1

1.3.x-devPHP ^7.4 || ~8.0 || ~8.1

1.4.0PHP ~8.0 || ~8.1 || ~8.2.0

1.6.0PHP ~8.1 || ~8.2.0

1.7.0PHP ~8.1 || ~8.2.0 || ~8.3

1.8.x-devPHP ~8.2.0 || ~8.3 || ~8.4

1.9.x-devPHP ~8.2.0 || ~8.3 || ~8.4 || ~8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/8e0bfb8bd80623a897951de63a7655d6d43798fde65f5f9263fc7619e86b689b?d=identicon)[gsteel](/maintainers/gsteel)

---

Top Contributors

[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (402 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (76 commits)")[![gsteel](https://avatars.githubusercontent.com/u/2803720?v=4)](https://github.com/gsteel "gsteel (76 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (75 commits)")

---

Tags

configurationarrayutilityconfigdot

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[league/config

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

564302.2M24](/packages/league-config)[symfony/options-resolver

Provides an improved replacement for the array\_replace PHP function

3.2k493.9M1.6k](/packages/symfony-options-resolver)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[voku/arrayy

Array manipulation library for PHP, called Arrayy!

4875.5M16](/packages/voku-arrayy)[dflydev/dot-access-configuration

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

13414.5M4](/packages/dflydev-dot-access-configuration)[jbzoo/data

An extended version of the ArrayObject object for working with system settings or just for working with data arrays

891.6M23](/packages/jbzoo-data)

PHPackages © 2026

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