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.
- 和更多
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
工匠
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:
---标题
:
入门描述
:
Install and configure the app.命令
:
1团体
:
基础知识---
Supported fields include
title
,
description
,
order
,
hidden
,
group
,
badge
,
redirect
,
tags
, 和
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:
使用
PeteBishwhip\Laradocs\Facades\Laradocs
;Laradocs
::
variables
(
fn
() => [
'版本'
=>
'1.0.0'
]);Laradocs
::
分享
(
'app_name'
,
配置
(
‘应用程序名称’
));Laradocs
::
宏
(
'tweet'
,
fn
(
大批
$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
工匠
laradocs:cachephp
工匠
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 。






