Framework overview
Application Flow
Follow a browser request to /products/42 from the product page example. Atom first prepares the application, then uses that setup to dispatch the request and render the page.
Enter through the front controller
Atom Starter's public/index.php loads Composer's autoloader and runs the application. run() calls handle() to obtain a response, then sends it to the browser. In a test, you can call handle($request) to inspect the response directly.
<?php
declare(strict_types=1);
require dirname(__DIR__) . "/vendor/autoload.php";
(new App\Application())->run();
Initialize the application
The first call to handle() initializes the application instance. Each step gives the next one something it needs:
- Resolve paths and load settings. Atom sets up aliases such as
@rootand@app, loads the environment files, and builds the configuration. A catalogue filename can come from these settings before any catalogue service is created. - Register services and build the injector. Atom gathers framework and application bindings. The catalogue provider binds
ProductServicetoSampleProductService, giving the injector a concrete class to supply toProductPage. - Set up the router and register features. Atom prepares the router, registers jobs and schedules, loads modules, and registers component tags and middleware. The application's
pages()hook points to@app/Pages. Atom discoversProductPagethere and registers the route declared by#[PageRoute("/products/{id}")]. - Run startup code. Atom runs provider bootstrappers, then the application's
bootstrap()hook. Use that hook for setup that needs the injector or router already in place, such as attaching an API controller.
Match the request and render the page
- Dispatch the request. Atom creates a request scope and dispatches through its middleware pipeline. The router matches
GET /products/42to the registered page route and capturesidas42. - Create the page and load its data. The injector creates
ProductPagewith itsProductService. Atom then callsget(string $id)with the route value. The handler loads the product and assigns it to the page's$productproperty. - Render and send the response. Since
get()returnsvoid, Atom rendersProductPage.atom.htmlwith the page instance available as$this. The template renders the product name and availability, and the shared layout places that HTML inside<main>. The front controller sends the resulting response.
For the route declaration and parameter binding in code, see Page routing. For the startup hooks and their responsibilities, see Application structure.
Repository Layout
If you are reading the framework source checkout, these are the starting points:
| Location | What you will find |
|---|---|
packages/framework/ |
The Atom runtime, including the application, router, injector, and template renderer. |
packages/starter/ |
The starter application and its public/index.php entry point. |
apps/sample/ |
A sample application that uses the framework from the same checkout. |
docs/ |
Framework source documentation. |
Getting started shows how to run the starter from that checkout or from the standalone distribution.