DOM.PHP #
Web Document PHP Markup & Components Framework
Build modern, semantic, ultra-fast web pages using declarative PHP. Zero dependencies required. Multi-format output by design.

Overview #
DOM.PHP is a declarative, component-driven framework that treats PHP as a complete domain-specific language (DSL) for web documents. It eliminates templating friction by letting you compose HTML5, modern responsive CSS, client-side AJAX interactions, and static assets in pure PHP — with zero build steps and zero dependencies.
<?php
include "dom.php";
use function dom\{init, main, h1, p, this};
init()->output(main(
h1("Hello World!").
p("This is a 'Hello World' example").
this()
));
Philosophy & Core Features #
- Declarative Markup DSL: Compose clean, valid HTML5 trees using functional PHP elements.
- High Performance & Natural Syntax: Direct evaluation into optimized string buffers without heavy in-memory AST overhead, preserving PHP's natural concatenation (
.) and comma chaining.
- State of the art HTML and CSS: Opinionated best CSS and HTML defaults.
- Transparent AJAX & Asynchronous Components: Turn any component asynchronous without writing separate API routes. The same file serves both full pages and partial components.
- Multi-Format by Design: Output HTML5, RSS 2.0, JSON Feed, Gemini, SW or PWA manifests from a single codebase.
- ...
Project Structure #
dom/ # DOM folder
├── dom.php # Master entry point (the single file to include)
├── plugins/ # Modular extensions & third-party providers
├── examples/ # Ready-to-run examples (hello-world, complete, templating, info)
└── README.md # This file
index.php # Your codebase
...
License & Credits #