Download the PHP package flyokai/composition without Composer
On this page you can find all versions of the php package flyokai/composition. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package composition
flyokai/composition
User docs →
AGENTS.mdTopological-sort helpers for declaring
before,after, anddependsrelationships between modules and pipeline items.
A thin layer on top of marcj/topsort that gives Flyokai a single, consistent way to order things — modules at bootstrap, ACL tuners, indexers, setup steps, anywhere a list needs to be deterministic.
Features
sortComposition(array $items)— sorts items bybefore/after/dependsdeclarationscastCompositionArgument(array $items, string $name, string $key)— sort + validate, returns ordered class namesassertCompositionKeys()— ensures every item has the keys it mustmergeDepends()— merge & dedupe dependency arraysArraySortGroup— extendsMJS\TopSort\Implementations\ArraySortwith grouping for parallel-safe execution
Installation
Quick start
Item shape
| Mechanism | Semantics |
|---|---|
before |
"this item comes before X" → X depends on this item |
after |
"this item comes after X" → this item depends on X |
depends |
direct dependency declaration |
before is intentionally inverted — 'before' => 'cache' means cache depends on the current item, not the other way.
Casting to ordered class names
assertCompositionKeys($items, ['className', 'tag'], 'pipelines') enforces that every entry contains the listed keys after sorting.
Group sorting
grouped() returns dependency cohorts — every item in a cohort can run in parallel without violating ordering.
Gotchas
beforeis inverted.'before' => 'cache'declares cache as depending on this item.- Missing dependencies throw —
ElementNotFoundException. No silent omission. - Cycles throw —
CircularDependencyExceptionvia parent tracking. - Adding elements after sorting invalidates the cached result; a full re-sort runs on next access.
- Accepts
'a,b',['a','b'], or empty string interchangeably (empties are filtered out).
See also
flyokai/applicationuses this for module ordering and DB setup steps.- amphp-injector ships its own
CompositionOrderedfor ordered DI compositions, built on the same primitives.
License
MIT