Development
This content is not available in your language yet.
This document describes development workflows and maintenance tasks for the project.
The examples page of an extension package (docs/examples.md in the package repository, synced to
src/content/docs/extensions/<package>/examples.md) shows a live demo of each PHP snippet when the package has
"demos": true in packages.json (Bootstrap 6 and FilePond).
- Renderer:
tools/bin/demos(run byprebuildaftertools/bin/reference, ornpm run demos) writes one Composer project per package in.cache/demos/<package>/fromtools/demos/composer.json, with Yii 22.0 and the package installed aspathrepositories from their synced checkouts and no Composer plugins, then renders the snippets in a separate PHP process. Each snippet runs in a freshyii\web\View($thisin the snippet, widget ids fromw0); the view lays out the page with the CSS, the module scripts and the script blocks the snippet registered. Assets are published from this repository’snode_modules(bootstrap, andfilepond, its plugins andcropperjs, are exact devDependencies) topublic/demos/assets/under stable names. Output:public/demos/<package>/<slug>.htmland the catalog.cache/demos/<package>.json(slug, title, snippet hash, source line, status, reason, assets), both git-ignored.--strictexits with 1 when a snippet fails or is skipped, andprebuildpasses it, so such a snippet fails the build;--helplists the options. - Page integration:
plugins/remark-demos.mjspairs eachphpcode block of the examples page with its demo (by a hash of the code) and replaces it, with thehtmlblock that follows, by a<docs-demo>block: Preview (an<iframe>of the demo page, so Bootstrap’s CSS never reaches the site), PHP and HTML tabs, defined bysrc/components/DocsDemo.astroand styled bysrc/styles/demos.css. The demo page follows the site theme and sizes its<iframe>(tools/demos/frame.js). Snippets without a demo keep their code blocks; the Markdown version of the page and thellmsbundles keep the code blocks only.postbuild(scripts/check-site.mjs) fails when an<iframe>or a demo asset is missing.
Writing examples that render
Section titled “Writing examples that render”Every php block runs as a demo, so write each one as code that works in a view:
- Echo the markup (
echo Alert::widget([...])) or usebegin()andend()in the same block. A block withbegin()and noend(), a configuration array (return [...]) or a class declaration is skipped, not failed. - Imports and variables carry over within a
##section: a block may use the classes imported by an earlier block, and a variable keeps the value of the first heading that defined it (the field examples use the$formof the first form). A block that declares ayii\base\Modelsubclass makes an instance of it available as$model. - A block that only registers scripts (for example showing a Toast) runs after the previous demo of its heading.
- Root-relative images (
/img/user.png) are replaced by a placeholder in the demo page; links and form submissions do not navigate. - A block that throws or raises a warning is reported as failed (
[demos] ... failed <slug> (docs/examples.md:<line>)) and fails the build; fix the example in the package repository.
To add a package, write its docs/examples.md in this style, add the npm packages its asset bundles publish from
@npm as exact devDependencies, set "demos": true in packages.json and run
SYNC_LOCAL=1 npm run build (or npm run sync:local && php tools/bin/demos).
The site theme lives in src/styles/theme.css, registered in customCss in astro.config.mjs before
src/styles/custom.css. Starlight keeps its own styles in CSS cascade layers; files in customCss are unlayered, so
their rules override Starlight without !important.
- Fonts: Atkinson Hyperlegible Next (text) and Atkinson Hyperlegible Mono (code), both under the SIL Open Font
License, installed from npm (
@fontsource-variable/atkinson-hyperlegible-next,@fontsource-variable/atkinson-hyperlegible-mono). Vite bundles thewoff2files intodist/_astro/; the build fetches nothing from the network. Each font is split byunicode-range, so a page downloads only the subsets it uses, and Starlight falls back to the system fonts for scripts they do not cover. - Type and layout:
--sl-text-*and--sl-line-heightset the type scale (17px body text, line height 1.7);--sl-content-width(56rem) and--sl-sidebar-width(17rem) set the text column and the left sidebar; on screens of 72rem and wider,--toc-width(15rem) fixes the “On this page” panel and the text column is centred in the remaining space. - Colours: the
:root[data-theme='dark']and:root[data-theme='light']blocks set Starlight’s grey scale (--sl-color-whiteto--sl-color-black, text to background), the accent (--sl-color-accent-low,--sl-color-accent,--sl-color-accent-high) and the inline code background (--sl-color-bg-inline-code). Code blocks follow these colours through Starlight’s default Expressive Code themes. After changing a colour, check that body text, links, headings, the sidebar and the table of contents keep a contrast ratio of at least 4.5:1 (WCAG AA) in both themes.
Extension skill sources
Section titled “Extension skill sources”The package skills/ folders are the editable sources. scripts/sync.mjs copies their complete portable bundles to
.cache/skills/ and public/skills/, rejecting duplicate names, invalid frontmatter, and linked resources outside a
bundle. Generated indexes record source refs and file checksums. Never edit or commit those outputs.
The guides remain package docs/, and API contracts remain PHPDoc. To add a skill-producing package, set its
skillsDir in packages.json, sync, run the preparation tests, then build. Publish package sources before a remote
build can consume newly declared skills. See skill installation.
Development tool guides
Section titled “Development tool guides”tools.json lists non-Composer repositories separately from packages.json. Tool entries use type: "tool",
name, title, repo, ref, localPath, docsDir, optional order, and optional skillsDir. They do not declare
PHP namespaces, Composer packages, API references or live PHP demos. scripts/sync.mjs imports their README and
package-owned guides into src/content/docs/development-tools/<name>/, and distributes skills through the same
checksum registry as extension skills. Generated pages are never edited or committed.
The navigation groups these guides under Development tools, separate from Extensions. Docker is maintained
in yii2-extensions/docker-images; fix its guides and skill there, then run npm run sync:local and build. A custom
--manifest sync excludes tools unless --tools-manifest=<path> is also supplied. Publish source changes before a
remote build can consume newly declared guides or skills.
External API links
Section titled “External API links”tools/external-references.json maps exact canonical PHP type and member names to verified HTTPS documentation or
source URLs. PHPStan targets use its 2.3 API reference; PHP Forge targets use source commits matching the inspected
dependency metadata. Builds read this registry without loading dependency runtime code or making network requests.
Verify target symbols and member anchors again when updating dependency versions; unknown members remain unresolved.
References to private members use their reflected source lines instead of inventing public catalog entries. Inherited descriptions remain visible on subclass pages, but unresolved diagnostics are counted on their defining type page, where the source can be repaired. The original package baseline limits remain unchanged; new clean packages start at zero for errors, warnings and unresolved references.