421c/autodoc-php
Autodoc-php automatically generates clear API documentation for Laravel and PHP applications by inspecting routes, controllers, and request/response definitions. Reduce manual docs, keep references up to date, and give teams a browsable, searchable overview of endpoints with minimal configuration.
composer show 421c/autodoc-php, inspect vendor/421c/autodoc-php/composer.json, the README, and the test suite. Pin an exact version ("421c/autodoc-php": "x.y.z") and commit the lockfile.composer require --dev 421c/autodoc-php.bin entry in composer.json (vendor/bin/...) or, in Laravel, a service provider with an Artisan command. Check extra.laravel.providers for auto-discovery and any publishable config (php artisan vendor:publish --tag=autodoc).npx @redocly/cli lint openapi.json (or Spectral). If it doesn't pass OpenAPI 3.1 validation, fix configuration before expanding scope.First useful outcome: a lint-clean spec for your health check and one CRUD resource, diffed against what you know the API actually returns.
Build-time generation, never request-time. Add a Composer script or Makefile target:
"scripts": { "docs": "autodoc generate --output=docs/openapi.json" }
Run it in CI, upload the artifact, or commit it to a docs branch. Serving it dynamically in development is fine if you cache on file mtimes; serving it per-request in production is not.
Incremental adoption via allowlists. Configure paths / include / exclude so only annotated namespaces are scanned, then expand coverage one PR at a time. Use an allowlist rather than a blocklist — blocklists leak internal endpoints into public specs.
Let code be the source of truth, annotate the gaps. Expect the generator to infer from type hints, return types, FormRequest rules, API Resources, and backed enums. Where it can't (unions, array shapes, generics like Collection<int, User>), supply attributes/docblocks or a manual override file that is merged after generation.
Treat the spec as a contract artifact. Generate → lint → oasdiff against main's spec → fail the build on breaking changes for public endpoints. Optionally feed the spec to Schemathesis or Dredd for contract tests.
One spec per bounded context in a monolith, with servers and tags distinguishing modules. This keeps diffs reviewable and avoids one giant contested file.
Define shared components once. Security schemes, 401/403/422/500 responses, pagination envelopes, and error shapes should live in a config-level components block or a base spec that gets merged, not repeated per endpoint.
Register customization through the package's extension points (type mappers, schema-name resolvers, attribute readers, post-processing hooks) rather than editing generated output. Keep overrides in source-controlled files so regeneration never clobbers them.
type: ["string", "null"], examples is an array, and schemas follow JSON Schema 2020-12. Older Swagger UI builds and some validators reject this. Confirm your renderer supports 3.1 before blaming the generator.mixed, array shapes, and conditional returns will need manual annotation. Budget for this; it is the main ongoing cost.$ref and a deterministic schema-naming strategy; check the config for cycle handling.How can I help you explore Laravel packages today?