PHPackages                             devly/repository - 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. devly/repository

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

devly/repository
================

PHP data repository object with array access using dot notation

1.1.0(2y ago)12.1k2PHPPHP &gt;=8.1

Since Oct 25Pushed 2y ago1 watchersCompare

[ Source](https://github.com/valenjeb/repository)[ Packagist](https://packagist.org/packages/devly/repository)[ RSS](/packages/devly-repository/feed)WikiDiscussions master Synced 1mo ago

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

Devly Repository
================

[](#devly-repository)

Provides an object to store and access data arrays with dot notation support.

Usage
-----

[](#usage)

A new data container instance can be created empty or from data provided as array, object or another `Devly\Repository` instance.

```
$repository = new \Devly\Repository();

// Or create with initial data
$repository = new \Devly\Repository(['user' => [...]]);
```

Can also be created using the static method `Devly\Repository::new()`

### set()

[](#set)

```
$repository->set('user.name', 'johndoe');

// Or as array
$repository['user.name'] = 'johndoe';

// Equivalent vanilla PHP
$array['user']['name'] = 'johndoe';
```

### get()

[](#get)

Retrieves data by key name

```
$username = $repository->get('user.name');

// Or as array
$username = $repository['user.name'];

// Equivalent vanilla PHP
$username = $array['user']['name'];
```

### has()

[](#has)

Check whether a key name exists

```
$repository->has('user.name');

// Or as array
isset($repository['user.name']);

// Equivalent vanilla PHP
isset($array['user']['name']);
```

### all()

[](#all)

Returns all the data as array

```
$array = $repository->all();
```

### remove()

[](#remove)

Removes given key

```
$repository->remove('user.name');

// Or as array
unset($repository['user.name']);
```

### clear()

[](#clear)

Removes all the data

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

### count()

[](#count)

Counts the number of items in the data container

```
$repository->count();

// Or using the count function
count($repository);
```

### isEmpty()

[](#isempty)

Checks whether the container contains data

```
$repository->isEmpty();
```

### toJson()

[](#tojson)

Returns a JSON representation of the data

Returns the value of a given key as JSON:

```
$repository->toJson('user');
```

Returns all the stored items as JSON:

```
$repository->toJson();

// Same as:
json_encode($repository);
```

### createFrom()

[](#createfrom)

Create a new Repository instance from an existing item

```
$repository  = new Repository(['name' => ['first' => 'John', 'last' => 'Doe']]);
$repository2 = $repository->createFrom('name');

$repository2->all(); // ['first' => 'John', 'last' => 'Doe']
```

### merge()

[](#merge)

Merge array, object or an instance of IRepository into the current Repository

```
$repository = new Repository(['first' => 'John', 'last' => 'Doe']);

$repository->merge(new Repository(['first' => 'Johnny']));

// Can also be merged with an object
$repository->merge((object) ['first' => 'Johnny']);

// Can also be merged with an object
$repository->merge(['first' => 'Johnny']);

$repository->all(); // ['first' => 'Johnny', 'last' => 'Doe']
```

### mergeRecursive()

[](#mergerecursive)

Merge array, object or an instance of IRepository into the current Repository recursively

```
$repository = new Repository(['name' => ['first' => 'John', 'last' => 'Doe']]);

$repository->mergeRecursive(['name' => ['first' => 'Johnny']]);

$repository->all(); // ['name' => ['first' => 'Johnny', 'last' => 'Doe']
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

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

Total

2

Last Release

917d ago

PHP version history (2 changes)1.0.0PHP ^7.4 || ^8.0

1.1.0PHP &gt;=8.1

### Community

Maintainers

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

---

Top Contributors

[![valenjeb](https://avatars.githubusercontent.com/u/7081274?v=4)](https://github.com/valenjeb "valenjeb (8 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/devly-repository/health.svg)

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

PHPackages © 2026

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