PHPackages                             hedronium/generator-nest - 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. hedronium/generator-nest

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

hedronium/generator-nest
========================

Generator delegation support for PHP5.

v1.0(9y ago)0351MITPHP

Since Dec 22Pushed 9y ago2 watchersCompare

[ Source](https://github.com/Hedronium/GeneratorNest)[ Packagist](https://packagist.org/packages/hedronium/generator-nest)[ RSS](/packages/hedronium-generator-nest/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (1)

GeneratorNest
=============

[](#generatornest)

[![Generator delegation Meme](https://camo.githubusercontent.com/70415aef54974218e58d5d10647b8252eb9a689902128801897636e75c2f4cac/687474703a2f2f692e696d6775722e636f6d2f4f48584d4f37552e6a7067)](https://camo.githubusercontent.com/70415aef54974218e58d5d10647b8252eb9a689902128801897636e75c2f4cac/687474703a2f2f692e696d6775722e636f6d2f4f48584d4f37552e6a7067)

PHP7 has native support for Generator Delegation (`yield from another_generator()`) but many projects still are written in PHP5 or need to support PHP5 for compatability reasons.

This little package has a generator that allows for generator delegation in PHP5.

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

[](#installation)

```
composer require hedronium/generator-nest
```

Usage
-----

[](#usage)

Consider that we have this generator.

```
function combinations($letters = [])
{
	$chars = ['a', 'b', 'c'];

	foreach ($chars as $char) {
		$merged = array_merge($letters, [$char]);

		yield implode('', $merged);

		if (count($letters) < 2) {
			yield combinations($merged);
		}
	}
}
```

If you try to iterate over a call to this generator like:

```
foreach (combinations() as $combination) {
	// your code
}
```

you'll recieve 3 strings and few generator objects as they are. This starts to be a problem because now in order to use this generator your calling code must be recursive which almsot defeats the whole purpose of using generators in the first place.

Enter Generator nest.

```
use Hedronium\GeneratorNest\GeneratorNest;

foreach (GeneratorNest::nested(combinations()) as $combination) {
	echo $combination, ' ';
}
```

now the output will simply be

```
a aa aaa aab aac ab aba abb abc ac aca acb acc b ba baa bab bac bb bba bbb bbc bc bca bcb bcc c ca caa cab cac cb cba cbb cbc cc cca ccb ccc

```

TADDA!

LICENSE
-------

[](#license)

MIT.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

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

Unknown

Total

1

Last Release

3427d ago

### Community

Maintainers

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

---

Top Contributors

[![omranjamal](https://avatars.githubusercontent.com/u/4700757?v=4)](https://github.com/omranjamal "omranjamal (2 commits)")

### Embed Badge

![Health badge](/badges/hedronium-generator-nest/health.svg)

```
[![Health](https://phpackages.com/badges/hedronium-generator-nest/health.svg)](https://phpackages.com/packages/hedronium-generator-nest)
```

###  Alternatives

[kryptonit3/counter

Hit counter for your pages.

8724.1k](/packages/kryptonit3-counter)

PHPackages © 2026

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