Skip to content
Sign in

Architecture

WBengine is a request-driven PHP framework with a visible object tree. It keeps site structure and content in MySQL, reusable behavior in namespaced PHP boxes, and presentation in templates.

The object tree

  • Application is the root of one HTTP request. It loads configuration and provides shared services such as database access, routing, authentication, rendering, Markdown and cache. Services are created lazily when used.
  • Site is the page selected for the current URL. It carries the site row, locale, access rules, metadata and navigation context.
  • Section is a named region in the page layout, for example header, central or footer.
  • Box is a small application component selected by a cms_boxes row. Its configured module and method map to a class in the application namespace, such as App\Box\Central\Docs.
  • Model contains reusable data access for a box. It uses the framework database layer and bound SQL parameters.
  • Renderer and template turn the box data into output. Templates use the framework renderer; they do not replace the PHP object tree.

The parent links are real object references: a box can reach its section, site and application without a second global container. Keep new PHP features in the existing tree and namespaces. Do not put credentials or database logic in templates.

One request from URL to HTML

Diagram of one request: entry, the application, a gate with the full-page cache, building every section and box, the layout and the response. A cache hit skips straight to the response.

  1. Entry. public/index.php loads Composer and the application bootstrap.
  2. Application. It serves an explicit application route or an enabled API route first, then resolves the language and matches the request to a Site.
  3. Gate. It checks access and whether a safe full-page cache entry can answer. A hit sends the stored copy and skips the rest.
  4. Build. It loads the active Sections of the Site. Each Section reads its configured Boxes. A Box is created with its parent objects, calls a Model when it needs database content, and the Renderer processes a .tpl file or a .md source.
  5. Layout. The output of the sections is combined in the site layout.
  6. Response. The HTTP response is returned and a safe public copy of the page is optionally stored.

The exact route and cache gates depend on application settings. The framework handles matching, access and rendering; application classes define what each box does.

What lives in the database and in PHP

cms_sites describes URLs and page metadata. cms_sections defines layout regions. cms_boxes attaches a module and method to a section, controls order and can mark a box as shared. Article, menu and translation tables hold editable content. PHP classes provide behavior, models query data, and templates present it. An existing box can often be attached to a new site through data alone; new behavior requires an application box class.

How to extend a site

For a content-only page, use an existing article or registered box and configure its site, section and box rows. For new behavior, add a class beneath App\Box\<Section>, extend Wbengine\Box\WbengineBoxAbstract, and use its parent accessors. Put reusable queries in a model and render a .tpl or .md source. The Boxes guide walks through the code and database mapping.

Markdown, templates, locales, caching and the server-to-server API v2 are described in their own guides. The optional central administration is a separate application connected through API v2; it is not part of the PHP request tree or Composer package.

Live on this request

The boxes that built this page

The site /docs/architecture/ (id 11) was matched in cms_sites. These cms_boxes rows belong to it, read by the same query the framework runs.

SectionBoxClass and methodShared
central Docs: Architecture docs::page() no
central Demo: structure demo::structure() no

Shared boxes are shown on every site. The order column decides the order inside a section.