Demos

Working examples demonstrating Be Framework concepts in action.

Hello World Demo

The simplest transformation. An Input with a name becomes a Final with a greeting.

HelloInput  →  Hello
(name)         (greeting)

Input (Potentiality)

#[Be([Hello::class])]
final readonly class HelloInput
{
    public function __construct(
        public string $name,
    ) {}
}

The #[Be] attribute declares what this Input can become.

Final (Actuality)

final readonly class Hello
{
    public string $greeting;

    public function __construct(
        #[Input] string $name,        // From HelloInput
        #[Inject] Greeting $greeting, // From DI container
    ) {
        $this->greeting = "{$greeting->greeting} {$name}";
    }
}

Reason (Raison d’être)

final class Greeting
{
    public string $greeting = 'Hello';
}

The name becomes a greeting by borrowing the external force of Reason. Here, Greeting provides ‘Hello’.

Usage

$input = new HelloInput(name: 'World');
$final = ($becoming)($input);

echo $final->greeting; // "Hello World"

Order Processing Demo

The Order Processing demo showcases the Diamond Metamorphosis pattern - where multiple parallel pipelines converge into a single Final state.

                OrderInput
                    │
        ┌───────────┼───────────┐
        ↓           ↓           ↓
   [inventory]  [payment]  [shipping]
        ↓           ↓           ↓
   InventoryReserved PaymentCompleted ShippingArranged
        │           │           │
        └───────────┼───────────┘
                    ↓
              OrderConfirmed

Key Concepts Demonstrated

Moment (契機)

Note: Moment is an evolving concept. The ideas presented here represent our current understanding and may be refined based on practical experience and feedback.

A Moment has three aspects:

  • Dynamis (δύναμις) - Realizable potential, becomes actuality through be()
  • Essential Aspect - An indispensable element constituting the whole
  • Part of Self - Not external, but an inner part of Final
final readonly class PaymentCompleted implements MomentInterface
{
    public PaymentCapture $capture;

    public function __construct(
        #[CardNumber] public string $cardNumber,
        #[Amount] public int $amount,
        #[Inject] PaymentGatewayInterface $gateway,
    ) {
        $this->capture = $gateway->authorize($cardNumber, $amount);
    }

    public function be(): void
    {
        $this->capture->be();  // Realize the potential
    }
}

Reason (存在理由)

Reason is where immanence meets transcendence - the stateless gateway connecting internal data to external systems or domain rules.

final class PaymentGateway implements PaymentGatewayInterface
{
    public function authorize(string $cardNumber, int $amount): PaymentCapture
    {
        $authCode = $this->api->authorize($cardNumber, $amount);

        return new PaymentCapture(
            $authCode,
            $amount,
            fn () => $this->capture($authCode, $amount),
        );
    }
}

Final (ἐνέργεια)

The convergence point where all Moments are realized through self-completion:

final readonly class OrderConfirmed
{
    public function __construct(
        #[Inject] public InventoryReserved $inventory,
        #[Inject] public PaymentCompleted $payment,
        #[Inject] public ShippingArranged $shipping,
    ) {
        // Self-completion: realize all parts
        $this->inventory->be();
        $this->payment->be();
        $this->shipping->be();
    }
}

Philosophical Foundations

The directory structure is grounded in ontological concepts.

Directory Description Concept
Input/ Holds potentiality—what something can become δύναμις (Aristotle)
Being/ Intermediate stages of transformation Dasein (Heidegger)
Moment/ Essential part constituting the whole Moment (Hegel)
Final/ Completed form of transformation ἐνέργεια (Aristotle)
Semantic/ Types with the power of validation and transformation Sinn (Frege)
Reason/ External force that enables existence Sufficient Reason (Leibniz)

“Be, Don’t Do”