KoniKode · Software built with intention

KNOWLEDGE BASE

Documentation

DOCUMENTATION
CURRENT APPLICATIONClean Framework
DocumentationClean Framework

Clean Framework · DOCUMENTATION

Wire dependencies explicitly

Wire dependencies explicitly

Steps

Use constructor injection and register application factories before freezing the container. Do not connect to a provider or start a session while registering dependencies.

// Inside composition, with these application dependencies already constructed.
$container->factory(DocumentationController::class, static fn (): DocumentationController =>
    new DocumentationController($documents, $markdown, $views, $csrf, $categories)
);
$container->freeze();

Use request-scoped or transient state for request-specific mutable values. Never retain a current user inside a singleton. See Container and the complete composition example.

Verify

Construct the kernel in an isolated test and assert that no session, runtime directory, database, or network call has started.

Editorial provenance

Source: resources/guides/injection.md. Source SHA-256: d54e6be6ce93cce46f37eb1e011c68a50e0e36cd27d0ab270c29ec1ae950831d.

Knowledge-base application source; editorial checkpoint 2026-10-20. See candidate status and adoption boundary.

EXPLORE FURTHER

Drag a divider or use Left and Right Arrow keys to resize. Hold Shift for larger steps. Enter hides or restores the sidebar; Home and End select its minimum or maximum width. Double-click resets the width.

Install KoniKode