windwalker / di
Windwalker DI package
Requires
- php: >=8.4.6
- psr/container: ^1.0||^2.0
- windwalker/attributes: ^4.0
- windwalker/data: ^4.0
- windwalker/utilities: ^4.0
Requires (Dev)
- phpunit/phpunit: ^13.0
- windwalker/test: ^4.0
Suggests
None
Provides
- psr/container-implementation: 1.0|2.0
Conflicts
None
Replaces
None
- 4.x-dev
- dev-master / 4.x-dev
- 4.2.11
- 4.2.9
- 4.2.8
- 4.2.7
- 4.2.6
- 4.2.5
- 4.2.4
- 4.2.3
- 4.2.2
- 4.2.1
- 4.2.0
- 4.2.0-beta1
- 4.1.x-dev
- 4.1.8
- 4.1.7
- 4.1.6
- 4.1.5
- 4.1.4
- 4.1.4-beta2
- 4.1.3
- 4.1.2
- 4.1.1
- 4.1.0
- 4.1.0-beta1
- 4.0.x-dev
- 4.0.29
- 4.0.27
- 4.0.26
- 4.0.25
- 4.0.24
- 4.0.23
- 4.0.22
- 4.0.21
- 4.0.20
- 4.0.19
- 4.0.18
- 4.0.17
- 4.0.16
- 4.0.15
- 4.0.14
- 4.0.13
- 4.0.12
- 4.0.11
- 4.0.10
- 4.0.9
- 4.0.8
- 4.0.7
- 4.0.6
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 4.0.0-beta2
- 4.0.0-beta1
- 3.x-dev
- 3.5.23
- 3.5.22
- 3.5.21
- 3.5.20
- 3.5.19
- 3.5.18
- 3.5.17
- 3.5.16
- 3.5.15
- 3.5.14
- 3.5.13
- 3.5.12
- 3.5.11
- 3.5.10
- 3.5.9
- 3.5.8
- 3.5.7
- 3.5.6
- 3.5.5
- 3.5.4
- 3.5.3
- 3.5.2
- 3.5.1
- 3.5
- 3.4.9
- 3.4.8
- 3.4.7
- 3.4.6
- 3.4.5
- 3.4.4
- 3.4.3
- 3.4.2
- 3.4.1
- 3.4
- 3.3.2
- 3.3.1
- 3.3
- 3.2.8
- 3.2.7
- 3.2.6
- 3.2.5
- 3.2.4
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2
- 3.1.6
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1
- 3.0.1
- 3.0
- 3.0-beta2
- 3.0-beta
- 2.1.9
- 2.1.8
- 2.1.7
- 2.1.6
- 2.1.5
- 2.1.4
- 2.1.2
- 2.1.1
- 2.1
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 2.0.0-beta2
- 2.0.0-beta1
- 2.0.0-alpha
- dev-test
This package is auto-updated.
Last update: 2026-11-28 11:21:43 UTC
README
Di
Windwalker DI package
Installation
composer require windwalker/di ^4.0
Child parameter scopes
Why branches are overlaid
Request-local configuration changes must not mutate shared parent configuration.
Previously, after a child called setDeep('user.remember.cookie_name', 'ADMIN'),
reading getDeep('user.remember') returned only cookie_name: the non-null local
array prevented fallback to the parent's enabled and expires settings.
Reading a complete leaf path could still succeed, so extracting or passing a
whole branch produced different results from reading individual settings.
Container children inherit parameters from their parent. Writing a deep path only
changes the child's local storage. get(), getDeep(), dump() and iteration
overlay local array branches on inherited branches, so sibling settings remain
available. Parent changes remain visible unless overridden locally.
Merge policy and compatibility
Array overlays follow Arr::mergeRecursive(): associative branches merge
recursively, lists concatenate, and an empty local array does not clear an
inherited array. Non-null scalar values override inherited values. Leaf reads
retain the existing null fallback; array snapshots retain explicit null entries
as dump() does.
Reusing the existing dump policy avoids introducing a second array merge policy for branch reads. The null distinction is intentionally retained for compatibility: reading a null leaf can fall back even when a returned branch contains that null. This overlay is not a deletion API; setting an empty array does not remove a branch.
Snapshots, proxies and references
extract() returns a detached snapshot of the merged branch. proxy() (or
extract($path, true)) keeps a live view and writes into the owning scope's local
storage, not its ancestor's storage. Proxy dumps and iteration contain only the
selected branch. Array overlays and inherited iteration are computed snapshots;
use set() / setDeep() or a proxy to write changes rather than modifying a
returned merged array by reference. getIterator(false) exposes local storage
without inherited values.
Extracting from the merged view prevents inherited siblings from disappearing in the snapshot, while retaining Collection's rejection of scalar extraction. Proxies reference local storage instead of materializing inherited branches, so writes stay isolated and later parent updates remain visible. Their parent view already contains local data; merging that data again would duplicate list items. Proxy path prefixes are delimiter-neutral so a dotted prefix also supports deep reads with a custom delimiter.
Inherited iteration yields each merged key once. Previously, yielding parent keys after local keys let array collectors overwrite child values with parent values. Merged iteration is a snapshot because a combined branch has no single backing storage to reference.
Aliases are resolved after inheritance lookup, in the reading scope. This lets an inherited reference observe a child override instead of resolving prematurely against the parent. Dumps use the same scoped resolution and restrict proxy output to its selected branch rather than including unrelated parent settings.