Download the PHP package dseguy/genie without Composer

On this page you can find all versions of the php package dseguy/genie. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package genie

genie — Systematic Value Generation for PHP

A PHP 8.2+ library for generating all values in a domain using lazy, composable iterators.

Use case: when code needs to walk an entire value domain — all letters, all digit pairs, all 3-character strings — this library provides the building blocks to express that concisely and memory-efficiently.

Installation

Requirements


Quick start


Primitive generators

Each primitive is a class with static factory methods. All generators are lazy — values are computed only when iterated.

Letters

Yields individual alphabetic characters.

Factory method Yields
Letters::lower() a … z (26 values)
Letters::upper() A … Z (26 values)
Letters::all() a … z then A … Z (52 values)

Digits

Yields integers over a bounded range.

Factory method Yields
Digits::all() 0 … 9
Digits::range(int $start, int $end, int $step = 1) integers from $start to $end inclusive, stepping by $step

Throws InvalidArgumentException if $start > $end or $step <= 0.

Booleans

Yields boolean (and optionally null) values.

Factory method Yields
Booleans::values() true, false
Booleans::withNull() true, false, null

Enums

Yields values derived from a PHP 8.1+ enum. Three factory methods cover the three things callers typically need from an enum.

Factory method Accepts Yields
Enums::cases(string $class) any enum the enum case objects (\UnitEnum instances)
Enums::names(string $class) any enum the case names as strings
Enums::values(string $class) backed enum only the backing values (int or string)

Throws InvalidArgumentException if the class is not an enum, or if values() is called on a pure (non-backed) enum.

Collection

Wraps an arbitrary PHP array as a generator source. Keys are discarded; only values are yielded.

Factory method Yields
Collection::of(array $items) every value in $items, re-indexed from 0

FromCallable

Wraps a factory callable that returns a \Traversable (generator, iterator, or iterator aggregate). The factory is invoked fresh on every iteration, making the source fully reusable and safe to use with all combinators.

Factory method Accepts Yields
FromCallable::of(callable $factory) callable(): \Traversable every value produced by the traversable, keys discarded

Warning — infinite sources: a factory that yields forever is valid with filter(), map(), and merge(), but will loop forever or exhaust memory inside product() or repeat(). There is currently no way to detect an infinite source at construction time; support for this is planned in a future version.

Permutations

Yields all ordered arrangements of $length distinct characters drawn from a charset. No character repeats within a single value.

Factory method Yields
Permutations::of(int $length, string $charset) All permutations of exactly $length distinct chars from $charset

Throws InvalidArgumentException if $length <= 0 or the charset has fewer than $length distinct characters.


Combinators

Combinators are methods available on every generator. They return a new generator and preserve laziness. Chain them in any order.

->merge(GeneratorInterface ...$others) — Union

Chains generators end-to-end into a single sequence.

->product(GeneratorInterface ...$others) — Cartesian product

Yields all combinations as flat arrays (one element per source generator).

Arrays from nested product() or repeat() calls are flattened — values spread into the result rather than nest.

->filter(callable $predicate) — Conditional filter

Excludes values for which $predicate returns falsy.

->map(callable $transform) — Transform

Applies a function to every yielded value.

->repeat(int $n) — Power (G^n)

Yields all $n-length sequences, with repetition allowed.

Each yielded value is a flat array. Throws InvalidArgumentException if $n <= 0.

repeat() vs Permutations: repeat() allows the same value to appear multiple times in one tuple; Permutations does not.


Pragmatic usage examples

Real-world scenarios where systematic value generation is useful.

Password / token brute-force testing

Generate all possible PIN codes or short alphanumeric tokens to verify a rate-limiter or lockout policy in tests.

Exhaustive unit test data providers

Feed a PHPUnit data provider with every combination of inputs rather than hand-picking a few.

Generating test fixtures

Populate a database or in-memory store with a systematic set of records.

Exhaustive enum coverage in tests

Iterate every case of an enum in a data provider so no case is accidentally omitted from test coverage.

Slug / identifier collision detection

Verify that a slug generator produces unique output across all inputs.

Scanning configuration ranges

Walk every valid port in a range, every HTTP status code, or every timeout value to verify system behaviour.

Character set validation

Probe a sanitiser or encoder against every character in a defined alphabet.

Generating SQL / query permutations

Build every variant of a parameterised query for fuzz-style integration tests.


Terminal method

After composing a chain, call ->toIterator() to obtain a plain \Iterator that can be assigned to a variable and passed around.

All generators also implement \IteratorAggregate, so they can be used directly in foreach without calling ->toIterator().


Composing chains

Combinators compose freely. Each step returns a new generator.


API reference

Namespace

Primitive generators

Class Factory methods
Letters lower(), upper(), all()
Digits all(), range(int $start, int $end, int $step = 1)
Booleans values(), withNull()
Enums cases(string $class), names(string $class), values(string $class)
Collection of(array $items)
FromCallable of(callable $factory)
Permutations of(int $length, string $charset)

GeneratorInterface

All generators implement GeneratorInterface, which extends \IteratorAggregate.

Method Returns Description
getIterator() \Generator Yields domain values
merge(...$others) GeneratorInterface Chain generators end-to-end
product(...$others) GeneratorInterface Cartesian product
filter($predicate) GeneratorInterface Filter by predicate
map($transform) GeneratorInterface Transform each value
repeat(int $n) GeneratorInterface All n-length sequences
toIterator() \Iterator Materialise the chain

Design principles


Out of scope (v1)


All versions of genie with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package dseguy/genie contains the following files

Loading the files please wait ...