endroid/documenter
endroid/documenter generates technical documentation automatically from your source code, using annotations to include resources in class diagrams, object descriptions, and other generated output. Install via Composer, with optional Symfony auto-wiring support.
endroid/documenter is a small, low-maturity library that generates technical documentation from annotated source files (class diagrams, object descriptions, and similar artifacts). The README is thin — the Usage section is literally empty — so treat the source and tests as the primary documentation.
Minimal steps:
composer require endroid/documenter:^x.y
src/ to identify:
.install/symfony. The package targets Symfony via endroid/installer; those config files show how the library expects to be wired. They are a useful reference even in Laravel, but they are not a Laravel integration.First real use case: annotate a handful of domain/service classes that are stable and public-facing, generate docs into a dedicated docs/generated/ directory, and diff the result in a PR. That gives you a feel for signal vs. noise before committing to it.
For Laravel specifically, assume no auto-discovery. You will need a small service provider binding and an Artisan command wrapper (see below).
1. Annotation-driven documentation on selected classes. Use the package's annotations on the classes you actually want documented — typically domain models, public services, and integration points. Resist annotating everything: generated docs are only useful when the annotated surface is intentional.
// Illustrative — verify the exact annotation names in src/
#[Document(resource: 'billing')]
class InvoiceService
{
// ...
}
2. Artisan command as the daily entry point. Wrap the generator in a command so the team has a single, memorable invocation:
class GenerateDocsCommand extends Command
{
protected $signature = 'docs:generate {--output=docs/generated}';
public function handle(Documenter $documenter): int
{
$documenter->generate($this->option('output'));
$this->info('Documentation generated.');
return self::SUCCESS;
}
}
Bind the documenter as a singleton in AppServiceProvider, reading paths and options from config/documenter.php. This keeps configuration out of the command and makes it environment-aware.
3. CI as the source of truth. Generate docs in CI and either commit them or publish them as an artifact. A typical workflow:
php artisan docs:generate in CI,This prevents documentation drift and makes review diffs meaningful.
4. Keep generated output out of application code.
Generate into a dedicated directory (docs/generated, build/docs) and exclude it from autoloading. If the tool emits class diagrams, verify whether an external binary (e.g., Graphviz) is required and install it in CI explicitly.
5. Layer with existing docs, not instead of them.
Use endroid/documenter for the structural/class-level view and keep hand-written README/ADR content for the narrative. Where the generated output is weak, supplement with phpDocumentor or your existing tooling rather than trying to force this package to do everything.
src/ and tests/. Tests are usually the most accurate usage examples in packages like this.vendor/. That keeps upgrades survivable.How can I help you explore Laravel packages today?