Documentation
How HexPHP Works
HexPHP is built on a zero-magic, component-based philosophy. Below is an overview of our request lifecycle.
1. The Entry Point: public/index.php
Every request is funnelled through the public/index.php front-controller. It loads the autoloader,
initializes basic configuration, and invokes the Router.
2. The Router: config/routes.php
The Router parses the $_SERVER['REQUEST_URI'] and matches it against defined routes mapped to
specific Controller classes and methods.
3. Controllers & Components
A Controller (e.g., HomeController) gathers data, sets the $title, and structures your
page. In HexPHP, we do not use traditional "views". Instead, Components are modular segments of
HTML. The assembly of these components into a complete, finished page is directly handled by the
Controller.
ob_start();
require BASE_PATH . '/app/Components/home_hero.php';
require BASE_PATH . '/app/Components/home_features.php';
$content = ob_get_clean();
require BASE_PATH . '/app/Layout/Framework.php';
Output buffering (ob_start()) is used to capture your components and inject them securely into the
main layout component.
4. The Layout
The layout is the outermost HTML wrapper. It provides the `head`, CSS, navigation, and footer, dumping whatever
component HTML you passed into the $content variable.