feat: Add API docs generation and llms.txt index#382
Conversation
The PHP SDK had no published API reference, unlike sibling WorkOS SDKs. This wires up phpDocumentor to emit both HTML (default) and Markdown (via saggre/phpdocumentor-markdown) into docs/_site so AI agents and humans share the same source paths, and adds a GitHub Pages workflow that builds and publishes on version tags.
The markdown pass already emits 700+ per-class .md files, but an LLM landing on the docs site has no curated entry point — it would have to crawl every file to find the top-level classes. An llms.txt at the site root (per llmstxt.org) gives agents a stable index of the Core, Service, and Exception classes, with the generated Resource DTO directory called out separately so it doesn't drown the list.
Greptile SummaryThis PR adds API documentation generation for the WorkOS PHP SDK using phpDocumentor, producing both HTML and parallel Markdown output in
Confidence Score: 3/5The deployment workflow will fail on every run due to missing composer setup, and the PHAR download lacks a version pin or integrity check in a job with write access to GitHub Pages. Two independent defects block the feature from working: the CI job never runs
|
| Filename | Overview |
|---|---|
| .github/workflows/docs.yml | New GitHub Pages deployment workflow; missing composer install step causes every CI run to fail at the Markdown documentation pass. |
| script/docs | Orchestrates HTML + Markdown doc generation and llms.txt; downloads phpDocumentor PHAR from an unpinned URL with no integrity verification, posing a supply-chain risk. |
| script/docs-serve | Simple local dev-server script; builds docs if not present then serves with PHP's built-in server. No issues found. |
| phpdoc.dist.xml | Standard phpDocumentor config pointing at lib/, outputting to docs/_site. No issues found. |
| composer.json | Adds saggre/phpdocumentor-markdown as a dev dependency for the Markdown template pass. No issues found. |
| .gitignore | Adds ignores for generated doc output, the downloaded PHAR, and phpDocumentor cache. No issues found. |
Sequence Diagram
sequenceDiagram
participant GH as GitHub Actions
participant Build as build job
participant PD as phpdoc.org
participant Pages as GitHub Pages
GH->>Build: "trigger (v* tag / workflow_dispatch)"
Build->>Build: checkout + setup-php
Note over Build: composer install missing
Build->>PD: curl phpDocumentor.phar (unpinned)
PD-->>Build: latest PHAR (no checksum)
Build->>Build: Pass 1 HTML output
Build->>Build: Pass 2 Markdown output (fails if vendor/ absent)
Build->>Build: Pass 3 generate llms.txt
Build->>Build: tar docs/_site to artifact.tar
Build->>Pages: upload-artifact
Pages-->>GH: deploy-pages
Reviews (1): Last reviewed commit: "feat: Generate llms.txt index in API doc..." | Re-trigger Greptile
| with: | ||
| php-version: '8.2' | ||
| tools: composer | ||
| - run: ./script/docs |
There was a problem hiding this comment.
Missing
composer install before running docs script
./script/docs checks for vendor/saggre/phpdocumentor-markdown/themes/markdown and immediately exits with an error (exit 1) if it's not found, but the workflow has no composer install step. Every CI run triggered by a tag push or workflow_dispatch will fail at the Markdown pass, producing no deployed site.
| # Pin a recent stable version; check https://github.com/phpDocumentor/phpDocumentor/releases for latest | ||
| curl -fsSL -o "$PHPDOC_PHAR" "https://phpdoc.org/phpDocumentor.phar" | ||
| chmod +x "$PHPDOC_PHAR" |
There was a problem hiding this comment.
Unpinned and unverified PHAR download
The comment says "Pin a recent stable version" but the URL https://phpdoc.org/phpDocumentor.phar always resolves to the latest release — there is no version pinned. More importantly, the downloaded PHAR is executed immediately with no integrity check (no SHA-256 comparison). If phpdoc.org serves a different binary or is compromised between runs, the malicious artifact will be run silently during every CI doc build.
Summary
docs/_site, so humans and AI agents share the same source paths.Publish API DocsGitHub Pages workflow that builds and deploys onv*tags (and on manual dispatch).llms.txtindex at the site root (per llmstxt.org) listing Core, Service, and Exception classes, with the 600+ generated Resource DTOs called out separately so they don't drown the list.Test plan
./script/docsruns cleanly locally and producesdocs/_site/index.html, parallel.mdfiles, anddocs/_site/llms.txt.llms.txtlists every class underlib/WorkOS,lib/WorkOS/Service, andlib/WorkOS/Exceptionwith working relative links../script/docs-serveserves the site for spot-checking.Publish API Docsworkflow viaworkflow_dispatchand confirm the Pages deploy succeeds.