Add an About page to a classic application.
- Create a project named architecture-lab.
- Inspect phpaml.json, public/, routes/, src/, and runtime/.
- Create an AboutController.
- Add GET /about to routes/WebApp.php.
- Return a simple HTML response, then verify it in the browser.
GUIDED SOLUTION
Build in request order.
aml create architecture-lab
cd architecture-lab
aml make:controller About
aml serveThe command creates the controller under src/controllers. Then add the route to routes/WebApp.php and connect it to AboutController::index. The route must be loaded before the browser can reach the action.
public function index(): Response
{
return Response::html('<main><h1>About</h1><p>My first PHPAML page.</p></main>');
}Open /about. A 200 response proves that entry point, router, controller, and response work together. A 404 generally means the route is not registered; a 500 means processing started and then failed.
Knowledge check
CHECK YOUR UNDERSTANDING
Why is the controller under src/ rather than public/?
Show the answer
Because the controller is internal code. Only public/index.php should be directly exposed to the Web.
CHECK YOUR UNDERSTANDING
Why is a route required?
Show the answer
It connects an HTTP method and path to the action that handles them.
SUMMARY
What to remember
- You can follow a complete request.
- You can distinguish public, application, and rebuildable code.
- You can distribute model, view, and controller responsibilities.
- You can now approach migration of an older project.