PHP Documentation Base
repository·master·Indexed 18 days ago
https://github.com/php/doc-baseBase source files and tools for converting PHP documentation from DocBook 5.2.1 XML into formats like HTML and RTF. Includes the PhD build tool, guidelines for authors and translators, and a suite of QA scripts (such as qaxml-tags.php and qaxml-attributes.php) to ensure structural consistency and XML validity in the PHP Manual.
What's inside php-doc-base
- The PHP Manual is built from source files using a tool called PhD. The documentation is written using the DocBook 5.2.1 XML schema. Contributions are made by volunteers who write original English content (authors) and translate it into other languages (translators).
Understand the PHP documentation build system
masterThe PHP documentation is a multi-stage pipeline that converts XML source files into the PHP pages seen on php.net/manual. The process involves four distinct components:
- doc- repositories*: Contain the raw XML documentation content (wording and structure) for various languages.
- doc-base: A validation and pre-processing tool that combines XML files, handles XInclude/XPointer links, and validates against DTDs.
- PhD (PHP DocBook): A rendering engine that converts the processed XML into
.phpfiles. It also generates search indices (JSON), CSS, images, and Table of Contents (TOC) files. - web-php: The web server component that serves the generated
.phpfiles. It provides the logic for page headers (navigation, search, breadcrumbs) and footers (copyright, contribution notes).
Availability of CHM builds
masterCHM (Compiled HTML) versions of the manual are built on an irregular schedule. Once rebuilt, they are automatically made available for distribution.How the PHP manual is built for the website
masterThe PHP manual and its translations are automatically rebuilt and published to PHP.net via an automated process managed by the PHP Systems team. This process occurs every few hours. If you notice issues with the manual content or translations on the website, you should contact the PHP Systems team atsystems@php.net.Use example output entities
masterWhen providing code examples, choose the correct entity based on whether the output is deterministic:
&example.outputs;: Use this when the output is guaranteed to be identical under all conditions.&example.outputs.similar;: Use this when the output might vary between different executions or different machine environments.
Glossary of PHP Manual terminology
masterWhen contributing to the PHP manual, the following terms are used:
- author: A person who contributes to the original English manual.
- translator: A person who translates the English manual into another language.
- {LANG}: A placeholder for your two-letter country code (e.g.,
doc-en@lists.php.net).
Note on Brazilian Portuguese: For the Git repository, use
pt_br, but for the mailing list suffix, usept-br.Understand the PHP Manual file structure
masterThe PHP Manual sources are organized by topic and extension. For extension documentation, files are located in
reference/extension_name/.Extension File Patterns
General Extension Files:
book.xml: The main container for the extension; includes other files (likeexamples.xml) and contains the preface.setup.xml: Contains setup, installation, and configuration documentation.configure.xml: If present, this is automatically included intosetup.xml.constants.xml: Lists constants declared by the extension.examples.xml: Contains various usage examples.versions.xml: Contains version information.[topic].xml: Custom topic files (e.g.,foo.xml) must be explicitly included viabook.xml.
Procedural Extensions (e.g.,
calendar):reference.xml: Container for the extension's functions.functions/: A directory containing one XML file per declared function.
Object-Oriented (OO) Extensions (e.g.,
imagick):classname.xml: Container for the methods of a class, including basic class information.classname/: A directory containing one XML file per method declared by the class. Note thatclassnamerefers to the lowercased name of the class.
Language-Specific Files
language-defs.ent: Contains local XML entities used by the language (e.g., main part titles).language-snippets.ent: Contains longer, frequently used translated XML snippets (e.g., warnings, notes).translation.xml: Stores central translation metadata (intro text, translator list). This file is unique to translation trees and is not in the English source.
What web-php does and its role in serving documentation
masterThe
web-phprepository is the runtime environment for php.net. It serves the.phpfiles generated by PhD and provides the functional logic for the site's UI components:- Global UI: Generates the top navigation, search bar, copyright, and privacy policy footers.
- Documentation UI: Generates page-specific headers (breadcrumbs, language dropdown) and footers (contribution call-outs, user notes).
- Asset Integration: Uses the CSS, images, TOC, and search index/description files generated by PhD to render the documentation pages and power the site's search functionality.
What PhD (PHP DocBook) does and its output
masterPhD is the rendering engine that transforms the combined XML, version files, and modification history files (produced by
doc-base) into the final.phpdocumentation pages.Key responsibilities include:
- PHP Page Generation: Produces
.phpfiles containing metadata (title, breadcrumbs, source path, last modified date, contributor list) and calls toweb-phpfunctions for headers and footers. - Search Assets: Writes
search-indexandsearch-descriptionJSON files. - Static Assets: Copies (or downloads) CSS files and images into the output directory.
- Navigation: Generates and saves Table of Contents (TOC) files used for the right-side navbar on documentation pages.
- PHP Page Generation: Produces
Manage `xml:id` patterns to avoid build failures
masterThe PHP Manual uses two distinct patterns for
xml:idattributes. Using the wrong pattern or duplicating IDs can cause build issues.Structural IDs: Used for linking and chunking on DocBook elements (like
<chapter>or<section>).- Pattern:
folder.id(single dot separator). - Behavior: The
configure.phpscript will generate warnings if it finds and removes duplicate Structural IDs.
- Pattern:
XInclude IDs: Used as targets for XIncludes.
- Pattern:
folder.id..local(double dot separator). - Behavior: The
configure.phpscript will remove duplicate XInclude IDs without generating warnings.
- Pattern:
Summary Table:
ID Type Pattern Purpose Structural folder.idLinking/Chunking XInclude folder.id..localXInclude targets How the EN-Revision system works
masterTo ensure translations stay synchronized with the English source, every translated file must include an
EN-Revisioncomment in its header. This comment contains the Git commit hash of the specific English file version that the translation is based on.If the commit hash in your translation's
EN-Revisionmatches the current commit hash of the English file, your translation is up-to-date. If they differ, the English source has changed, and your translation needs to be updated to reflect those changes.<!-- EN-Revision: [commit_hash] Maintainer: [username] Status: ready -->What doc-base does and how it processes XML
masterThe
doc-basetool is responsible for validating and combining documentation XML files. It uses aconfigure.phpscript to perform the following operations:- Pulls version information from repository files.
- Iterates through the language repository starting from a skeleton/main table of contents (
index.php) to include all elements with appropriate IDs. - Pulls the modification history file.
- Generates file entities from the source language directory and writes them back to the same directory.
- Loads the combined XML into memory.
- Executes all
XIncludeandXPointerlinks. - Substitutes entities.
- Validates the final document against its DTD.