PHP CAP publication example — 9 November 2026

Article:
https://blog.alert-hub.org/posts/cap-ecosystem/2026-11-09-php-cap-content-negotiation/

Newly written teaching material. No editor source or credentials are included.
This bundle does not change or deploy CAP Editor.

Requirements: PHP 8.2+, DOM, XSL, Composer; NGINX and PHP-FPM on Linux.
The lock file records the dependencies used to check this example. Review and
update dependencies against the target runtime before deployment.

1. Put this directory outside the web document root, e.g. /srv/cap-publication.
2. Run composer install --no-dev and composer check-platform-reqs --no-dev.
3. Review the public-storage boundary and source-name syntax. No per-source
   list is maintained: validated source names map directly to the same S3
   prefix. Publishing new objects creates new resources automatically. Expose
   public objects only; drafts/private objects must not share this key space.
   For mixed/private storage, use an exact authoritative publication-registry
   lookup before retrieval; never load a full source table to filter in PHP.
4. Supply AWS region/credentials through the SDK credential chain, preferably a
   read-only workload role. Configure PHP-FPM environment access as required;
   it may clear inherited environment variables. Never embed access keys here.
5. Review/adapt styles/rss.xsl and styles/cap.xsl, including language labels,
   mobile layout, full alert semantics and the actual production stylesheet needs.
6. Adapt nginx.conf inside the existing cap.alert-hub.org TLS virtual host.
   Change the fixed script path and FPM socket for this installation. Check
   the virtual host for location conflicts, inherited caching and headers.
7. Use a dedicated bounded FPM pool; set request_terminate_timeout and memory
   limits. Turn display_errors off; monitor private logs and rendering failures.
8. Run nginx -t and stage HTTP checks before advertising canonical URLs.
9. Change generated RSS/item/share URLs as described in the article. Preserve
   CAP bytes, item GUIDs, existing S3 URLs, objects and retention policies.

Routing:
/public/do-indomet-es/rss -> feed=do-indomet-es
/public/do-indomet-es/{name} -> feed=do-indomet-es&alert={name}
Appending .xml selects a fixed XML representation, ignoring Accept.
Without a suffix, Accept selects machine XML or text/html; wildcard/missing
Accept defaults to machine XML. Equal qualities prefer machine XML. Unsupported
types return 406; the example does not provide application/xml aliases.

Verification: PHP 8.3.36, libxslt 1.1.42, NGINX 1.26.3,
Symfony HttpFoundation 7.4.23, AWS SDK 3.403.1.
38 local HTTP checks passed through NGINX and PHP-FPM with fictional fixtures
and an in-memory AWS SDK transport: XML/HTML, weighted preferences, q=0,
wildcards, missing/unsupported/parameterised Accept, fixed .xml, HEAD/405,
query overrides, restricted script access, unknown source/key, storage denial,
size limits, DTD rejection, escaped text, multilingual CAP and legacy RSS links.
The mock transport was used only in the test copy; it is not in this bundle.
Live AWS access, production configuration and existing publisher stylesheets
require deployment-specific verification. Output size is checked after transform;
this is not a hard CPU/memory sandbox or a CAP/signature validator.

Optional publisher stylesheet mapping
------------------------------------
approved-stylesheet.php is a helper to opt into publisher-selected presentation.
The default xsltprocessor.php is unchanged and uses bundled stylesheets.
Follow the article's integration snippet; create a deployment-owned
approved-stylesheets.php mapping, place reviewed XSLT in styles/approved/,
and pin each approved file's SHA-256. The public URL in the instruction is
resolved and looked up, never fetched. Mapping keys include source and kind.
Absent/unapproved/unsupported/malformed instructions, missing local files and
hash mismatches select the bundled stylesheet. Transform errors still return
502 through the main processor. Preserve all its parser and processor controls.
The helper supports one prolog association, explicit text/xsl or
application/xslt+xml type, simple screen/all media, no alternate sets and only
href/type/media/alternate attributes. Other syntax falls back conservatively.
The caller logs fallback and can set X-CAP-Stylesheet: bundled-fallback; add a
visible HTML notice for a public deployment. Approvals/configuration must be
read-only to the runtime. No sample approval is enabled in this bundle.

Optional helper verification: 23 selection, fallback and transformation checks
passed using PHP 8.3.36 and the bundled dependency lock. Checks cover approved
relative/absolute references, source/kind isolation, absent/changed files,
hash mismatch, outside-directory paths, malformed/multiple/unsupported
instructions, non-HTTPS/private-network references and original DOM retention.

Source registration is independent of stylesheet approval. New public sources
use bundled rendering automatically. The article's approval array is illustrative;
production approval records can be managed in a registry and looked up by exact
source, document kind and resolved stylesheet URL. No PHP edits per new feed.

Source-scaling revision: 46 HTTP checks passed through NGINX and PHP-FPM
with mocked S3, including three new source names with no source configuration
changes, invalid names, missing objects and the existing negotiation checks.
