petebishwhip / laradocs
Maintain beautiful, version-controlled documentation alongside your Laravel codebase. Markdown in, a polished docs site out.
Fund package maintenance!
Requires
- php: ^8.3
- devizzent/cebe-php-openapi: ^1.1
- illuminate/contracts: ^11.14 || ^12.0 || ^13.0
- illuminate/support: ^11.14 || ^12.0 || ^13.0
- league/commonmark: ^2.4
- ralphjsmit/laravel-seo: ^1.8
- spatie/yaml-front-matter: ^2.0
Requires (Dev)
- larastan/larastan: ^2.9 || ^3.0
- laravel/mcp: ^0.8
- laravel/pint: ^1.18
- laravel/scout: ^11.2
- meilisearch/meilisearch-php: ^1.0
- nyholm/psr7: ^1.5
- orchestra/testbench: ^9.0 || ^10.0 || ^11.0
- orchestra/workbench: ^9.0 || ^10.0 || ^11.0
- pestphp/pest: ^3.0 || ^4.0
- pestphp/pest-plugin-laravel: ^3.0 || ^4.0
- phpstan/phpstan: ^1.11 || ^2.0
- rector/rector: ^1.2 || ^2.0
- simonhamp/the-og: ^0.8
- vimeo/psalm: ^6.16
Suggests
- dedoc/scramble: Generate your OpenAPI spec with Scramble instead of the built-in native generator. Requires ^0.13 for Laravel 13 support. Select with laradocs.openapi.generator.driver=scramble (or leave it on auto) after installing.
- laravel/mcp: Expose your docs as an MCP server so AI assistants can search and browse them. Enable with LARADOCS_MCP=true after installing.
- laravel/scout: Power full-text docs search with Meilisearch, Typesense or Algolia (falls back to a built-in JSON index).
- nyholm/psr7: When using Meilisearch via Scout, install a PSR-17 factory (nyholm/psr7, guzzlehttp/psr7 ^2, or symfony/http-client) so the Meilisearch SDK can build HTTP requests.
- simonhamp/the-og: Generate Open Graph / social card images for pages that don't declare their own (the default OgImageGenerator).
This package is auto-updated.
Last update: 2026-07-05 11:54:34 UTC
README
Maintain beautiful, version-controlled documentation inside your Laravel
codebase. Write markdown, commit it next to the code it describes, and Laradocs
serves a polished docs site at /docs (or wherever you like).
composer require petebishwhip/laradocs php artisan laradocs:install
Then open /docs.
Requirements
| Minimum | Notes | |
|---|---|---|
| PHP | 8.3 | 8.4 and 8.5 fully supported |
| Laravel | 11.14 | 12 and 13 fully supported |
| dedoc/scramble | 0.13 | Optional β only needed for the scramble OpenAPI driver |
Features
- π Multi-level file structure β nested folders become nested navigation.
- π Filename or metadata routing β
slug:front-matter overrides paths. - π Markdown β HTML powered by CommonMark (GFM, tables, footnotes, β¦).
- π·οΈ Rich per-file metadata β
title,description,order,hidden,group,badge,redirect,tags, and more. - π¨ Polished default UI β responsive, dark-mode, sidebar, breadcrumbs, on-page table of contents, prev/next β all publishable and overridable.
- β‘ Smart caching β rendered HTML cached and auto-invalidated on file change.
- π§© Variables & macros β interpolate
{{ values }}and reuse@docs()blocks, with a service-provider API to register your own. - πΌοΈ Rich content β callouts (
> [!NOTE]), syntax-highlighted code with a copy button, lazy images with captions, and local/YouTube/Vimeo video embeds. - π Automatic SEO β
<title>, meta description, Open Graph & Twitter cards, canonical URLs and JSON-LD for every page, with per-page front-matter overrides. - πΊοΈ Sitemap β an auto-generated
sitemap.xmlat{prefix}/sitemap.xml, cached and invalidated alongside the rest of the docs cache. - β Fully tested β Pest + Testbench, 100% coverage gate, PHPStan & Psalm max, Pint.
Quick start
Create a page:
php artisan make:doc guide/getting-started --title="Getting Started" --order=1
--- title: Getting Started description: Install and configure the app. order: 1 group: Basics --- # Getting Started > [!TIP] > Folders become sidebar sections; `_index.md` is a section's landing page.
Configuration
Everything is configurable in config/laradocs.php and via environment
variables β route prefix/domain, docs path, routing strategy, theme, caching and
more. See the Configuration docs.
LARADOCS_ROUTE_PREFIX=docs LARADOCS_THEME=auto LARADOCS_ENABLED=true
The Laradocs facade
use Laradocs\Facades\Laradocs; Laradocs::variables(fn () => ['version' => '1.0.0']); Laradocs::share('app_name', config('app.name')); Laradocs::macro('tweet', fn (array $args) => "<a href=\"...\">@{$args['user']}</a>");
Artisan commands
| Command | Description |
|---|---|
laradocs:install |
Publish config and scaffold a starter page |
make:doc {name} |
Scaffold a new markdown page with front-matter |
laradocs:cache |
Pre-render and cache every page |
laradocs:clear |
Clear the documentation cache |
laradocs:openapi |
Generate an OpenAPI spec from your routes (--driver=auto|native|scramble) |
Publishing
php artisan vendor:publish --tag=laradocs-config php artisan vendor:publish --tag=laradocs-views php artisan vendor:publish --tag=laradocs-assets php artisan vendor:publish --tag=laradocs-lang
Testing
composer test
Local development (workbench)
The package ships an orchestra/testbench workbench β a disposable Laravel app used to run Laradocs as a real, browsable site while you work on the package itself, rather than through Pest alone.
composer serve
This builds the workbench (testbench workbench:build) and boots it at
/docs. The generated app lives at vendor/orchestra/testbench-core/laravel
β it's regenerated on demand and isn't committed to git.
By default the workbench has no docs content, so /docs renders an empty
state. Point it at the real docs in this repo (so edits under docs/ show up
immediately, thanks to Laradocs' mtime-based cache) by adding to the
workbench's .env:
# vendor/orchestra/testbench-core/laravel/.env LARADOCS_PATH=/absolute/path/to/laradocs/docs
Or seed your own throwaway fixtures directly under the workbench's docs/
and lang/vendor/laradocs/<locale>/ β useful for exercising a specific
feature (a locale, a version, a front-matter combination) without touching
the real docs. Any config/laradocs.php option can be set via the
workbench's own .env, exactly as in a consumer app β e.g.
LARADOCS_LOCALE_AVAILABLE={"en":"English","fr":"FranΓ§ais"} to test
localisation.
For finer control than composer serve gives you β e.g. driving the app with
curl instead of a browser β build and serve it yourself:
composer run build # just (re)build the workbench, don't serve cd vendor/orchestra/testbench-core/laravel php artisan config:clear # pick up .env changes β Laravel may have cached the old config php artisan serve # or: php -S 127.0.0.1:8000 -t public public/index.php
Two gotchas worth knowing:
composer dump-autoloadwipes the workbench. The package'spost-autoload-dumphook runstestbench package:purge-skeleton, which deletes the generated app β including any.envchanges or fixtures you added. Re-runcomposer run build(orcomposer serve) afterwards to regenerate it.- Config changes need
config:clear. After editing the workbench's.env, runphp artisan config:clearinside it if the change doesn't seem to take effect.
Documentation
The full docs live at laradocs.dev/docs β and are themselves built with Laradocs. Highlights:
- Getting started
- Configuration
- Routing
- Metadata
- Caching
- SEO
- Sitemap
- CLI reference
- PHP API
- Variables Β· Macros Β· Rich content
- Customising the UI Β· Customising stubs
- Migration guide: 0.x β 1.0
The source for those pages lives in docs/; browse there or serve a
local copy with composer serve.
Sponsors
Laradocs is free and open source. If it saves you time, please consider sponsoring its development β it keeps the project actively maintained.
The image above is regenerated daily by the Scheduler
workflow via sponsorkit.
Contributing & Security
See CONTRIBUTING.md and SECURITY.md.
License
The MIT License (MIT). See LICENSE.md.