Repository navigation
Rule 1 Config 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.
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.
-
bootstrap/container.phpbuilds the container once, fromconfig/container.phpand an optionalconfig/site.php, where a client site can change any binding without touching core. -
hammerand the control panel are the two entry points:bootstrap/hammer.phpandbootstrap/cp.php. - Settings from
.envarrive as one small typed object,src/Support/AppConfig.php, built in the container. No class reads$_ENVitself. - Lists are wired the same way:
console.commands,doctor.php_checksanddoctor.host_checksare built withDI\add(), so a site adds a command or a check without changing core.
Small scripts that are thrown away (the code in a spike) may read their config directly. They are not part of core.
Entry point, container, binding, core, client site. See Glossary.
PHP 8.5 OOP Mastery, Rule 1 in its course philosophy, taught in modules 3 and 4, dependency injection and container automation. Course page.