Skip to content

Rule 1 Config at the entry point

Edward Baitsewe edited this page Nov 9, 2026 · 1 revision

Rule 1: Config and the container belong at the entry point

Part one: wiring. Objects get what they need through their constructor. Only the entry point knows how everything is wired.

The short form of every rule is in BUILD_PHILOSOPHY.md, which is the version that counts. This page is the long form: why, where it shows today, and when not to use it.

Why

When a class fetches its own dependencies ($container->get(...), getenv(...), reading a config file), the dependency is still there; it is only hidden. You cannot see it in the constructor, you cannot replace it in a test, and a client site cannot swap it without editing core. Wiring everything in one place makes every dependency visible and every one replaceable.

Where it shows in Slim Killer

  • bootstrap/container.php builds the container once, from config/container.php and an optional config/site.php, where a client site can change any binding without touching core.
  • hammer and the control panel are the two entry points: bootstrap/hammer.php and bootstrap/cp.php.
  • Settings from .env arrive as one small typed object, src/Support/AppConfig.php, built in the container. No class reads $_ENV itself.
  • Lists are wired the same way: console.commands, doctor.php_checks and doctor.host_checks are built with DI\add(), so a site adds a command or a check without changing core.

When not to apply it

Small scripts that are thrown away (the code in a spike) may read their config directly. They are not part of core.

Words

Entry point, container, binding, core, client site. See Glossary.

Learn more

PHP 8.5 OOP Mastery, Rule 1 in its course philosophy, taught in modules 3 and 4, dependency injection and container automation. Course page.


Build philosophy

Clone this wiki locally