SILLBEAM HANDBOOK · v0.4.0

Modules

Describe business domains with descriptors and direct module dependencies.

Overview

BASH
php bin/console sillbeam:make:module User
php bin/console sillbeam:make:module Checkout --project=Shop

A #[SillbeamModule] descriptor owns its directory and subdirectories. The file and descriptor class names must comply with PSR-4. IDs are derived from the class name without Module, or specified with id:. Two modules cannot own the same directory or nested directories.

PHP
<?php

declare(strict_types=1);

namespace App\Module\Billing;

use App\Module\Payment\PaymentModule;
use Sillbeam\Core\Module\Attribute\SillbeamModule;

#[SillbeamModule(
    id: 'billing',
    description: 'Invoices',
    dependencies: [PaymentModule::class],
)]
final class BillingModule
{
}

Every direct static reference to a class in another module requires its descriptor in dependencies. Checks cover types (including union/intersection), inheritance, interfaces, traits, attributes, new, static access, ::class, instanceof and catch types. Dynamic class names, PHPDoc, string service IDs and code outside modules are not checked. Unused imports do not count; descriptor metadata is not checked as business references.

Shared modules may only use other shared modules. Private modules may also use private modules in the same Project. The architecture check reports missing targets, forbidden dependencies and cycles across the declared catalog. It checks business references in active source modules, which may not use inactive modules.

enabled means the module is eligible for activation (default: true). active means it belongs to a compiled active graph. Without Projects, all enabled shared modules are active. With Projects, shared modules are included through explicit assignment or as direct or transitive dependencies; enabled private modules are included in their owning Project’s graph. Unassigned shared modules can be enabled but inactive.

YAML
sillbeam:
    modules:
        billing: { enabled: false }
        'project:shop:reports': { enabled: false }

If an active graph requires a disabled target, the architecture check reports a violation. Cache preparation can still succeed. A disabled private module is not an automatic root of the Project graph. Explicit native imports can bypass automatic selection and remain the application’s responsibility.

Core derives IDs from CamelCase. For example, OrderHistoryModule becomes order-history. In Project mode, a disabled dependency of a shared module that is itself inactive does not constitute an architecture violation on its own.

The complete Billing/Payment example shows descriptors, a direct code reference, the actual build error and the correction.

Technical reference: published Core tag v0.2.0, commit cf2f4102ad7c15db30ad5c5af21852bc2aaec99a in the Core repository. Historical verification records identify their own source snapshots separately. The unchanged contracts were checked against the published Core v0.3.0.

In addition, code.unknown_class checks unresolved static application types in Module and Project code, including descriptor constructors and inactive modules. Ownership follows Composer PSR-4 and discovery paths; external library types are excluded. Tests/Fixtures and bare optional attribute names retain their exemptions. Target files are not executed for resolution.

References to indexed application classes outside all modules appear as informational application couplings. They create no module dependency, activation or violation. See Architecture for boundaries and dynamic cases.

Checked module references

Each supported direct static access to a class in another module must list that module’s descriptor in dependencies. Core checks references including types, inheritance, traits, attributes, new and ::class. Transitive module declarations do not cover a direct access.

Dynamically assembled class names, PHPDoc, string service IDs and unused imports are outside these checks. The module guide covers scope rules and examples.