SILLBEAM HANDBOOK

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 shared modules. Private modules may use shared modules and private modules of the same Project. Missing targets, disallowed boundaries and cycles are build errors. Active code cannot use an inactive module. Business reference checks apply to active source modules; the declared architecture is checked across the entire catalog.

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 build fails. A disabled private Module is not an automatic Project root. Explicit native imports can bypass automatic selection and remain the application’s responsibility.

IDs are derived from CamelCase: OrderHistoryModule becomes order-history. In Project mode, a disabled dependency of a Shared Module that is itself inactive does not alone prevent a build. Unknown declared targets, forbidden module boundaries and cycles are checked across the entire catalog.

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.