-
Notifications
You must be signed in to change notification settings - Fork 1
Add Directory Layout convention page (EN/JA) #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c096a73
Add Directory Layout convention page (EN/JA)
koriym 2704777
Tighten directory-layout page: Wittgenstein epigraph, drop filler
koriym 0407795
Restructure directory-layout page around per-directory code samples
koriym e304bf7
Refine directory-layout captions and sync EN/JA
koriym File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,225 @@ | ||
| --- | ||
| layout: docs-en | ||
| title: "Be Framework Directory Layout" | ||
| category: Convention | ||
| permalink: /manuals/1.0/en/convention/directory-layout.html | ||
| --- | ||
|
|
||
| # Be Framework Directory Layout | ||
|
|
||
| > "The facts in logical space are the world." | ||
| > | ||
| > —Ludwig Wittgenstein (*Tractatus Logico-Philosophicus*, 1.13, 1921) | ||
|
|
||
| ## Source map | ||
|
|
||
| | dir | role | manual | | ||
| |---|---|---| | ||
| | `src/Input/` | Pipeline entry. Declares `#[Be(...)]`. | [Input Classes](../02-input-classes.html) | | ||
| | `src/Final/` | Terminus. `#[Input]` data + `#[Inject]` services. | [Final Objects](../04-final-objects.html) | | ||
| | `src/Semantic/` | Semantic variables. Class name = parameter name. | [Semantic Variables](../06-semantic-variables.html) | | ||
| | `src/Exception/` | Semantic-validation exceptions with `#[Message]` for i18n. | [Error Handling](../09-error-handling.html) | | ||
| | `src/Reason/` | Raison d'être — capabilities an existence requires, gathered into one. | [Reason Layer](../08-reason-layer.html) | | ||
| | `src/Module/` | Ray.Di modules. `MODULE=<name>` env switches the active module. | [Ray.Di Manual](https://ray-di.github.io/manuals/1.0/en/index.html) | | ||
| | `src/Becoming/` | Framework wiring — `BecomingInterface` implementations/decorators. | [Becoming](../04a-becoming.html) | | ||
| | `src/Being/` | Branching — `$being` discriminator + `#[Be([A, B])]`. | [Being Classes](../03-being-classes.html) | | ||
| | `src/LogContext/` | Semantic-log event classes attached to `Been`. | [Semantic Logging](../10-semantic-logging.html) | | ||
| | `src/Moment/` | Moment — holds a Potential from Reason, realized via `be()`. | [Metamorphosis Patterns](../05-metamorphosis-patterns.html) | | ||
|
|
||
| ## `src/Input/` | ||
|
|
||
| ```php | ||
| #[Be(HelloFinal::class)] | ||
| final readonly class HelloInput | ||
| { | ||
| public function __construct( | ||
| #[Input] public string $name, | ||
| ) {} | ||
| } | ||
| ``` | ||
|
|
||
| An Input is the first domain class, built from data handed in from outside. `#[Be(...)]` declares what it becomes next — one candidate, or several. | ||
|
|
||
| → [Input Classes](../02-input-classes.html) | ||
|
|
||
| ## `src/Final/` | ||
|
|
||
| ```php | ||
| final readonly class HelloFinal | ||
| { | ||
| public string $message; | ||
|
|
||
| public function __construct( | ||
| #[Input] string $name, | ||
| #[Inject] Greeting $greeting, | ||
| ) { | ||
| $this->message = $greeting->say($name); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| The terminus of metamorphosis. No `#[Be(...)]`. `#[Input]` is immanence (what came from the previous form); `#[Inject]` is transcendence (services from outside). Evidence of completion is recorded via `#[Inject] Been`. | ||
|
|
||
| → [Final Objects](../04-final-objects.html) | ||
|
|
||
| ## `src/Semantic/` | ||
|
|
||
| ```php | ||
| final class Email | ||
| { | ||
| #[Validate] | ||
| public function validate(string $email): void | ||
| { | ||
| if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { | ||
| throw new InvalidEmailException(); | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| The class name becomes the parameter name. `#[Validate]` auto-applies to every argument named `$email`, anywhere in the app — define once, enforced everywhere. | ||
|
|
||
| → [Semantic Variables](../06-semantic-variables.html) | ||
|
|
||
| ## `src/Exception/` | ||
|
|
||
| ```php | ||
| #[Message( | ||
| en: 'Invalid email: {email}', | ||
| ja: '不正なメールアドレス: {email}', | ||
| )] | ||
| final class InvalidEmailException extends \DomainException {} | ||
| ``` | ||
|
|
||
| `#[Message]` `en`/`ja` declare the per-language message. Placeholders like `{email}` are assigned from the exception's properties at throw time. | ||
|
|
||
| → [Error Handling](../09-error-handling.html) | ||
|
|
||
| ## `src/Reason/` | ||
|
|
||
| ```php | ||
| final readonly class ExpressShipping | ||
| { | ||
| public function __construct( | ||
| private PriorityCarrier $carrier, | ||
| private RealTimeTracker $tracker, | ||
| ) {} | ||
|
|
||
| public function calculateFee(Weight $weight): Fee | ||
| { | ||
| return $this->carrier->expressFee($weight); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| "What does it take to exist as `ExpressDelivery`?" — `ExpressShipping` is the answer. It gathers the capabilities that existence requires into one class, usable as `#[Inject]` to provide capabilities, or as the type of `$being` to decide the next form. | ||
|
|
||
| → [Reason Layer](../08-reason-layer.html) | ||
|
|
||
| ## `src/Module/` | ||
|
|
||
| ```php | ||
| final class AppModule extends AbstractModule | ||
| { | ||
| protected function configure(): void | ||
| { | ||
| $this->bind(PriorityCarrier::class)->to(FedExPriority::class); | ||
| $this->bind(RealTimeTracker::class)->to(FedExTracker::class); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| DI bindings swapped via an env var like `MODULE=Dev`. A `DevModule` or `TestModule` substitutes implementations without touching the production `AppModule`. | ||
|
|
||
| → [Ray.Di Manual](https://ray-di.github.io/manuals/1.0/en/index.html) | ||
|
|
||
| ## `src/Becoming/` | ||
|
|
||
| ```php | ||
| final readonly class LoggingBecoming implements BecomingInterface | ||
| { | ||
| public function __construct( | ||
| private Becoming $inner, | ||
| private LoggerInterface $logger, | ||
| ) {} | ||
|
|
||
| public function __invoke(object $input): object | ||
| { | ||
| $this->logger->info('becoming', ['input' => $input::class]); | ||
| return ($this->inner)($input); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Touched rarely — only when you need to instrument metamorphosis itself (logging, tracing, timing). | ||
|
|
||
| → [Becoming](../04a-becoming.html) | ||
|
|
||
| ## `src/Being/` | ||
|
|
||
| ```php | ||
| #[Be([Approved::class, Rejected::class])] | ||
| final readonly class ApplicationReview | ||
| { | ||
| public Approved|Rejected $being; | ||
|
|
||
| public function __construct( | ||
| #[Input] LoanApplication $app, | ||
| #[Inject] CreditCheck $check, | ||
| ) { | ||
| $this->being = $check->evaluate($app); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Which class comes next is declared by the union-typed `$being` property. In practice, the framework picks the `#[Be([...])]` candidate whose constructor arguments can be satisfied. | ||
|
|
||
| → [Being Classes](../03-being-classes.html) | ||
|
|
||
| ## `src/LogContext/` | ||
|
|
||
| ```php | ||
| final class EmailFormatAssertedContext extends AbstractContext | ||
| { | ||
| public const string TYPE = 'email_format_asserted'; | ||
| public const string SCHEMA_URL = '../schemas/email-format-asserted.json'; | ||
|
|
||
| public function __construct( | ||
| public readonly string $email, | ||
| ) {} | ||
| } | ||
| ``` | ||
|
|
||
| `TYPE` is the event name that lands in the log; `SCHEMA_URL` links to the schema. Inside a Final, `$been->with(new EmailFormatAssertedContext(...))` records the evidence that the object was established. | ||
|
|
||
| → [Semantic Logging](../10-semantic-logging.html) | ||
|
|
||
| ## `src/Moment/` | ||
|
|
||
| ```php | ||
| final readonly class PaymentCompleted implements MomentInterface | ||
| { | ||
| public PaymentCapture $capture; | ||
|
|
||
| public function __construct( | ||
| #[Input] string $cardNumber, | ||
| #[Input] int $amount, | ||
| #[Inject] PaymentGateway $gateway, | ||
| ) { | ||
| $this->capture = $gateway->authorize($cardNumber, $amount); | ||
| } | ||
|
|
||
| public function be(): void | ||
| { | ||
| $this->capture->be(); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| The constructor completes `authorize()` (the Potential), but not `capture()`. Only a Final that could construct *every* Moment then calls `be()` on each — so partial commits never happen. | ||
|
|
||
| → [Metamorphosis Patterns](../05-metamorphosis-patterns.html) | ||
|
|
||
| --- | ||
|
|
||
| Three directories — `Being/`, `LogContext/`, `Moment/` — ship empty. Add classes as the project needs them. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.