PHPackages                             nabeghe/yielder - 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. nabeghe/yielder

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

nabeghe/yielder
===============

A similar alternative to yield in PHP for reading values from arrays, with a touch of zest.

1.0.0(1y ago)44MITPHPPHP &gt;=7.4

Since Oct 11Pushed 10mo ago1 watchersCompare

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

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

Yielder for PHP ≥ 7.4
=====================

[](#yielder-for-php--74)

> A similar alternative to yield in PHP for reading values from arrays, with a touch of zest.

Retrieve the value of the next index in an array whenever you want, or define the values as callables so that their contents can be returned when needed. This is likely just the beginning or the end of this package library!

🫡 Usage
-------

[](#-usage)

### 🚀 Installation

[](#-installation)

You can install the package via composer:

```
composer require nabeghe/yielder
```

### Example 1: Value

[](#example-1-value)

Each time, the array returns the value of the next index.

```
use Nabeghe\Yielder\Yielder;

$data = [
    'value 1',
    'value 2',
    'value 3',
];

$value = Yielder::value($data, $index);
echo "Index $index: $value\n"; // Index 0: value 1

$value = Yielder::value($data, $index);
echo "Index $index: $value\n"; // Index 1: value 2

$value = Yielder::value($data, $index);
echo "Index $index: $value\n"; // Index 2: value 3

$value = Yielder::value($data, $index);
echo "Index $index: $value\n"; // Index -1: null

Yielder::reset($data);

$value = Yielder::value($data, $index);
echo "Index $index: $value\n"; // Index 0: value 1
```

### Example 2: Each

[](#example-2-each)

Iterating through the array using the `value` method.

```
$data = [
    'value 1',
    'value 2',
    'value 3',
];

Yielder::each($data, function ($value, $index) {
    echo "Index $index: $value\n";
    // return true if you want to break.
});
```

### Example 3: Value Call

[](#example-3-value-call)

Imagine you have an array that contains data, but instead of placing the data directly in each index, you can define them as callables. This way, they can be executed when needed, returning their values.

This is something like lazy loading.

```
use Nabeghe\Yielder\Yielder;

$data = [
    function () {
        return 'Value 1';
    },
    function () {
        return 'Value 2';
    },
    function () {
        return 'Value 3';
    },
];

$value = Yielder::valueCall($data, $index);
echo "Index $index: $value\n"; // Index 0: value 1

$value = Yielder::valueCall($data, $index);
echo "Index $index: $value\n"; // Index 1: value 2

$value = Yielder::valueCall($data, $index);
echo "Index $index: $value\n"; // Index 2: value 3

$value = Yielder::valueCall($data, $index);
echo "Index $index: $value\n"; // Index -1: null

Yielder::reset($data);

$value = Yielder::valueCall($data, $index);
echo "Index $index: $value\n"; // Index 0: value 1
```

### Example 4: Each Call

[](#example-4-each-call)

Iterating through the array, but exactly like `valueCall`.

```
use Nabeghe\Yielder\Yielder;

$data = [
    function () {
        return 'Value 1';
    },
    function () {
        return 'Value 2';
    },
    function () {
        return 'Value 3';
    },
];

Yielder::eachCall($data, function ($value, $index) {
    echo "Index $index: $value\n";
    // return true if you want to break.
});
```

📖 License
---------

[](#-license)

Licensed under the MIT license, see [LICENSE.md](LICENSE.md) for details.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance46

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

583d ago

### Community

Maintainers

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

---

Top Contributors

[![nabeghe](https://avatars.githubusercontent.com/u/12207627?v=4)](https://github.com/nabeghe "nabeghe (3 commits)")

---

Tags

arraylazy-loadinglazyloadlibraryphpyieldyielderarraylibraryyieldlazy loadyielder

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nabeghe-yielder/health.svg)

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

###  Alternatives

[doctrine/collections

PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.

6.0k411.1M1.2k](/packages/doctrine-collections)[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k295.3M2.5k](/packages/symfony-property-access)[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)[league/config

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

564302.2M24](/packages/league-config)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[league/iso3166

ISO 3166-1 PHP Library

69536.3M116](/packages/league-iso3166)

PHPackages © 2026

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