-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add Practice section (P1 Quick Start, P2 Tutorial) #13
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
5 commits
Select commit
Hold shift + click to select a range
c0158b4
feat: add Practice section (P1 Quick Start, P2 Tutorial)
koriym 0a1d5eb
refactor: simplify file names (remove P1/P2 prefix)
koriym dceb9a1
fix: address review feedback
koriym 018b10e
fix: add simplified note to JTAS protocol
koriym 70f3d6e
feat: add Japanese translations for Getting Started and Tutorial
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| --- | ||
| layout: docs-en | ||
| title: "Getting Started" | ||
| category: Manual | ||
| permalink: /manuals/1.0/en/getting-started.html | ||
| --- | ||
|
|
||
| # Getting Started | ||
|
|
||
| > Now that you understand the philosophy, let's put it into practice. | ||
|
|
||
| ## Requirements | ||
|
|
||
| - PHP 8.4+ | ||
| - Composer | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| git clone https://github.com/be-framework/app my-project | ||
| cd my-project | ||
| rm -rf .git | ||
| composer install | ||
| ``` | ||
|
|
||
| ## Run the Example | ||
|
|
||
| ```bash | ||
| php bin/app.php | ||
| ``` | ||
|
|
||
| Output: | ||
|
|
||
| ```txt | ||
| Hello World | ||
| ``` | ||
|
|
||
| That's it! Let's look at the code. | ||
|
|
||
| ## Project Structure | ||
|
|
||
| ``` | ||
| src/ | ||
| ├── Input/ | ||
| │ └── HelloInput.php # Starting point | ||
| ├── Final/ | ||
| │ └── Hello.php # Destination | ||
| ├── Reason/ | ||
| │ └── Greeting.php # Transcendent capability | ||
| ├── Semantic/ | ||
| │ └── Name.php # Validation rules | ||
| ├── Exception/ | ||
| │ └── EmptyNameException.php | ||
| └── Module/ | ||
| └── AppModule.php # DI configuration | ||
| ``` | ||
|
|
||
| ## The Code | ||
|
|
||
| ### Input Class | ||
|
|
||
| ```php | ||
| #[Be([Hello::class])] | ||
| final readonly class HelloInput | ||
| { | ||
| public function __construct( | ||
| public string $name | ||
| ) {} | ||
| } | ||
| ``` | ||
|
|
||
| The `#[Be]` attribute declares the **destiny**—what this input will become. | ||
|
|
||
| ### Final Class | ||
|
|
||
| ```php | ||
| final readonly class Hello | ||
| { | ||
| public string $greeting; | ||
|
|
||
| public function __construct( | ||
| #[Input] string $name, | ||
| #[Inject] Greeting $greeting, | ||
| ) { | ||
| $this->greeting = "{$greeting->greeting} {$name}"; | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| - `#[Input]` receives data from the previous stage (HelloInput) | ||
| - `#[Inject]` receives **Transcendence** (capability from outside) | ||
|
|
||
| ### Reason Class | ||
|
|
||
| ```php | ||
| final class Greeting | ||
| { | ||
| public string $greeting = 'Hello'; | ||
| } | ||
| ``` | ||
|
|
||
| The Greeting provides the **transcendent capability**—the power to greet. | ||
|
|
||
| ### Executing Metamorphosis | ||
|
|
||
| ```php | ||
| $injector = new Injector(new AppModule()); | ||
| $becoming = new Becoming($injector, 'Be\\App\\Semantic'); | ||
|
|
||
| $input = new HelloInput('World'); | ||
| $hello = $becoming($input); | ||
|
|
||
| echo $hello->greeting; // "Hello World" | ||
| ``` | ||
|
|
||
| ## What Just Happened? | ||
|
|
||
| ``` | ||
| HelloInput('World') | ||
| ↓ Becoming executes | ||
| Hello (with Greeting injected) | ||
| → "Hello World" | ||
| ``` | ||
|
|
||
| The input didn't "do" anything—it **became** Hello through metamorphosis. | ||
|
|
||
| ## Try Semantic Validation | ||
|
|
||
| Edit `bin/app.php` to pass an empty name: | ||
|
|
||
| ```php | ||
| $input = new HelloInput(''); | ||
| ``` | ||
|
|
||
| Run again: | ||
|
|
||
| ```bash | ||
| php bin/app.php | ||
| ``` | ||
|
|
||
| You'll see an error message because `Semantic/Name.php` validates that name cannot be empty. | ||
|
|
||
| ## Key Concepts Demonstrated | ||
|
|
||
| | Concept | In This Example | | ||
| |---------|-----------------| | ||
| | **Immanence** | `$name` in HelloInput | | ||
| | **Transcendence** | `Greeting` injected via `#[Inject]` | | ||
| | **Metamorphosis** | HelloInput → Hello transformation | | ||
| | **Semantic Validation** | Name.php validates input | | ||
|
|
||
| ## Next Steps | ||
|
|
||
| Ready for a more complete example with Being classes and branching? Continue to [Tutorial](./tutorial.html) → | ||
|
|
||
| Or revisit the concepts: | ||
| - [Input Classes](./02-input-classes.html) - Starting points | ||
| - [Final Objects](./04-final-objects.html) - Destinations | ||
| - [Semantic Variables](./06-semantic-variables.html) - Validation | ||
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.