This guide describes the detailed bootstrap flow of the Marwa Framework.
flowchart TD
A[HTTP Request] --> B[public/index.php]
B --> C[Application Created]
C --> D[Container Initialized]
D --> E[.env Loaded]
E --> F[Core Services Bound]
F --> G[HttpKernel Boot]
G --> H[AppBootstrapper]
H --> I[Providers]
I --> J[DatabaseBootstrapper]
J --> K[Modules Loaded]
K --> L[Middleware Pipeline]
L --> M[Router Matches Route]
M --> N[Controller/Handler Executes]
N --> O[Response Created]
O --> P[HttpKernel Terminates]
P --> Q[Response Sent]
flowchart TD
A[CLI Command] --> B[marwa entrypoint]
B --> C[Application Created]
C --> D[ConsoleKernel Boot]
D --> E[CommandRegistry]
E --> F[Discover Commands]
F --> G[Execute Command]
G --> H[Output Result]
// public/index.php
$app = new Application(__DIR__ . '/..');
.env file// Inside HttpKernel
$app->bootstrap();
// Handle request
$response = $kernel->handle($request);
classDiagram
class Application {
+boot()
+make()
+handle()
}
class HttpKernel {
+handle(request)
+terminate(response)
}
class Container {
+addShared()
+get()
}
class AppBootstrapper {
+bootstrap()
}
class ProviderBootstrapper {
+bootstrap(providers)
}
class DatabaseBootstrapper {
+bootstrap()
}
class ModuleBootstrapper {
+bootstrap()
}
Application --> Container
HttpKernel --> Application
HttpKernel --> AppBootstrapper
AppBootstrapper --> ProviderBootstrapper
AppBootstrapper --> DatabaseBootstrapper
AppBootstrapper --> ModuleBootstrapper
| Phase | Services | Description |
|---|---|---|
| 1 | Config, Storage | Basic services |
| 2 | Logger, Events | Logging and events |
| 3 | Cache, HTTP, Mail | Request services |
| 4 | Notifications | Notification channels |
| 5 | Session, Security | Web services |
| 6 | Error Handler | Early handler registration and config-aware tuning |
| 7 | Database | Database connection |
| 8 | Providers | Custom providers |
| 9 | Modules | Module loading |
flowchart LR
A[Request] --> B[RequestIdMiddleware]
B --> C[SessionMiddleware]
C --> D[MaintenanceMiddleware]
D --> E[SecurityMiddleware]
E --> F[RouterMiddleware]
F --> G[Route Handler]
G --> H[Response]
B -.->|add X-Request-ID| A
C -.->|init session| B
D -.->|check mode| C
E -.->|apply security| D
F -.->|dispatch route| E
flowchart TD
A[ConsoleKernel] --> B[CommandRegistry]
B --> C[Built-in Commands]
B --> D[Config Commands]
B --> E[Discovered Commands]
B --> F[Module Commands]
B --> G[Package Commands]
C --> H[Symfony Console]
D --> H
E --> H
F --> H
G --> H
The framework uses lazy loading for optimal performance:
// Eager loading (before)
$container->addShared(Service::class, new Service());
// Lazy loading (current convention)
$container->addShared(Service::class, fn () => new Service());
Services that are lazy-loaded: