PHPackages                             salarmehr/ary - 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. salarmehr/ary

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

salarmehr/ary
=============

A php array/stdClass alternative to store configs, options and more.

2.0.0(1w ago)85.0k3[1 PRs](https://github.com/salarmehr/ary/pulls)MITPHPPHP &gt;=5.6.0

Since Oct 1Pushed 1w ago1 watchersCompare

[ Source](https://github.com/salarmehr/ary)[ Packagist](https://packagist.org/packages/salarmehr/ary)[ RSS](/packages/salarmehr-ary/feed)WikiDiscussions main Synced yesterday

READMEChangelog (2)Dependencies (3)Versions (18)Used By (0)

Ary
===

[](#ary)

**Ary** is a lightweight, zero-dependency PHP class that gives arrays and objects a single, unified interface. It's a handy alternative to plain arrays or `stdClass` for storing configs, options, registries, environment variables, and any data whose shape changes conditionally — or whenever you want to chain operations over an array.

It's so convenient that, after a while, you'll miss it in projects that don't have it.

Features
--------

[](#features)

- Access items with either object (`->`) or array (`['']`) syntax — interchangeably.
- Missing keys return `null` (or a default you choose) instead of emitting a notice.
- Get and set values inside deeply nested arrays using **"dot" notation**.
- Behaves like a regular array: works with `count()`, `unset()`, `foreach`, and `json_encode()`.
- Handy helpers: `get`, `has`, `all`, `toArray`, `toObject`, `only`, `except`, `replace`, `replaceRecursively`, and `ary` (sub-ary).
- **No dependencies** — just PHP. A single small class with no framework required.

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

[](#installation)

Install with Composer:

```
composer require salarmehr/ary
```

Requires **PHP 5.6** or above.

Usage
-----

[](#usage)

### Instantiation

[](#instantiation)

```
$ary = new Ary();
// or, using the helper:
$ary = ary();
```

### Initialization

[](#initialization)

```
$ary = ary(2, 4, 6, 8);              // from a list of values
$ary = ary([2, 4, 6, 8]);            // from an array
$ary = ary(['x' => 'foo', 'y' => 'bar']);
```

### Assignment

[](#assignment)

```
$ary->newItem = 20;     // object syntax
$ary['newItem'] = 20;   // array syntax
```

### Retrieval

[](#retrieval)

```
$foo = $ary->x;         // object syntax
$foo = $ary['x'];       // array syntax

// supply a default for missing keys (no notice, no error):
$value = $ary->get('missing', 'Default value');

$ary->all();            // returns the underlying plain PHP array
```

### Works like a regular array

[](#works-like-a-regular-array)

```
count($ary);
unset($ary[0]);
json_encode($ary);

foreach ($ary as $key => $value) {
    // ...
}
```

### Deep (dot-notation) access

[](#deep-dot-notation-access)

```
$ary = ary(['products' => ['desk' => ['price' => 100]]]);

$price = $ary['products.desk.price'];   // 100

$ary['products.table.weight'] = 200;    // creates the nested path
```

### A few of the helpers

[](#a-few-of-the-helpers)

```
$ary->only(['x', 'y']);          // a new Ary with only those keys
$ary->except(['x']);             // a new Ary without those keys
$ary->replace(['x' => 'new']);   // shallow replace, returns a new Ary
$ary->toObject();                // cast to a stdClass
$ary->ary('products');           // a sub-Ary for a nested key
```

License
-------

[](#license)

MIT

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance98

Actively maintained with recent releases

Popularity25

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity67

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

Recently: every ~800 days

Total

15

Last Release

8d ago

Major Versions

v0.11 → 1.0.02018-12-24

v0.12 → 2.0.02026-06-25

PHP version history (2 changes)v0.2PHP &gt;=5.4.0

2.0.0PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/d7e3170f70349e934d4bbea0f5ac07d45357dc6e44c3c3d117953fb1c65eccd1?d=identicon)[salarmehr](/maintainers/salarmehr)

---

Top Contributors

[![salarmehr](https://avatars.githubusercontent.com/u/2582036?v=4)](https://github.com/salarmehr "salarmehr (53 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/salarmehr-ary/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[illuminate/pagination

The Illuminate Pagination package.

12234.1M1.0k](/packages/illuminate-pagination)[illuminate/pipeline

The Illuminate Pipeline package.

9349.2M282](/packages/illuminate-pipeline)[illuminate/redis

The Illuminate Redis package.

8314.6M375](/packages/illuminate-redis)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)

PHPackages © 2026

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