Maintaining Context & Developer Experience
FW solves common architectural challenges through Explicit Compilation and Strict Typing.
How Developers and Agents Maintain Project Awareness
Declarative Truth over Imperative Discovery: Instead of needing to read dozens of PHP files to understand the routing matrix or the database schema, developers only need to read two files:
database/schema.yaml: The absolute truth of the data layer.api/*.yaml: The absolute truth of the external API surface. Runningfw build:apiandfw build:dbguarantees the underlying PHP code correctly reflects those changes.
Zero Runtime Reflection (Static Container): Because the dependency injection container (
build/container.php) is generated at compile time, static analysis tools (or PHPStan/Psalm) can analyze exactly what dependencies are injected where, without needing to execute the application.Strict Data Mapper ORM (No N+1): By using strictly typed
readonly classModels (e.g.,UserModel), you know exactly what data is available. Accidental N+1 queries are eliminated entirely, as queries must be explicitly formulated in the Repository.
Standard Tools & Workflows
When working on an FW application, you should rely on these tools:
FW CLI (
php fw):fw build:api: Regenerates routes, handlers, and DTOs fromapi/*.yaml.fw build:db: Regenerates typed models and repository interfaces fromdatabase/schema.yaml.fw build:migrations: Dumps pure SQL schema diffs.fw build:container: Autowires the entire dependency graph via AST/Reflection into a static file.
PHPStan (Level 8 or 9) & Psalm (Level 1): FW is designed to pass strict static analysis seamlessly. Since everything is explicitly typed and compiled, running
vendor/bin/phpstan analysewill instantly tell you if your assumptions about types or method signatures are wrong.Modular Architecture: We enforce a strict
modules/directory structure. Context can be isolated tomodules/User/without needing to ingest the entiremodules/Orders/domain.
MSPs (Modular Service Providers) in Development
While developing the FW framework itself (or applications using it), having continuous background tools is highly beneficial:
- File Watchers: A tool like
chokidarornpm run watch(if set up) that listens to file changes and automatically triggers:php fw build:containerdocker compose restart app(to refresh the Swoole memory loop)vendor/bin/phpstan analyse
- Continuous Testing: A background worker running
pestorphpunitimmediately on save.
By relying on compilation and strict typing, you never have to "guess" how the application will behave at runtime.