Version-Controlled Documentation Inside Your Laravel App with Laradocs

Published on by

Version-Controlled Documentation Inside Your Laravel App with Laradocs image

Laradocs is a Laravel package that serves a documentation site from markdown files kept inside your codebase. You write the docs next to the code they describe, commit them together, and Laradocs renders them at /docs with navigation, search-friendly metadata, and a responsive UI.

  • 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.
  • And more

Folder Structure Becomes Navigation

Laradocs builds its sidebar from your directory layout. Nested folders turn into sections, and an _index.md file acts as a section's landing page. Routing follows the filenames by default, but you can override a path with a slug field in front-matter when you want a URL that differs from the file location.

Scaffold a new page with the generator command:

php artisan make:doc guide/getting-started --title="Getting Started" --order=1

Front-Matter Metadata

Each page carries metadata in YAML front-matter that controls how it appears in navigation and search:

---
title: Getting Started
description: Install and configure the app.
order: 1
group: Basics
---

Supported fields include title, description, order, hidden, group, badge, redirect, tags, and slug. Markdown is processed through CommonMark with GitHub-flavored markdown, tables, and footnotes, plus callout blocks using the familiar GitHub syntax:

> [!TIP]
> Folders become sidebar sections; `_index.md` is a section's landing page.

Variables and Macros for Reuse

To avoid repeating values across pages, Laradocs lets you register shared variables and reusable macro blocks from a service provider. Variables interpolate into markdown with {{ value }} syntax, and macros render with an @docs() block:

use PeteBishwhip\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>");

SEO, Caching, and Output

Rendered pages get automatic meta tags, Open Graph and Twitter card data, and JSON-LD, along with a generated sitemap at {prefix}/sitemap.xml. Laradocs caches rendered pages and invalidates the cache when source files change. You can also pre-render every page ahead of time or clear the cache manually:

php artisan laradocs:cache
php artisan laradocs:clear

The package requires PHP 8.2+ and supports Laravel 11, 12, and 13. You can learn more on the Laradocs website and view the source on GitHub.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Laravel Code Review

Get expert guidance in a few days with a Laravel code review

Visit Laravel Code Review
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $9500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell

The latest

View all →
Worker Metrics on the WorkerStopping Event in Laravel 13.18 image

Worker Metrics on the WorkerStopping Event in Laravel 13.18

Read article
Clonio CLI: Clone Production Databases With Anonymized Data image

Clonio CLI: Clone Production Databases With Anonymized Data

Read article
Ship AI with Laravel: Test Your AI System with Zero API Calls image

Ship AI with Laravel: Test Your AI System with Zero API Calls

Read article
Laravel WhatsApp: Two Backends Behind One Facade image

Laravel WhatsApp: Two Backends Behind One Facade

Read article
Turn PHP Attributes Into Docs With Signal image

Turn PHP Attributes Into Docs With Signal

Read article
USAIGE: Track Token Usage and Costs for Laravel AI SDK Requests image

USAIGE: Track Token Usage and Costs for Laravel AI SDK Requests

Read article