petebishwhip/laradocs
Composer 安装命令:
composer require petebishwhip/laradocs
包简介
Maintain beautiful, version-controlled documentation alongside your Laravel codebase. Markdown in, a polished docs site out.
README 文档
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.
Star History
petebishwhip/laradocs 适用场景与选型建议
petebishwhip/laradocs 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.25k 次下载、GitHub Stars 达 86, 最近一次更新时间为 2026 年 06 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「documentation」 「markdown」 「docs」 「laravel」 「commonmark」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 petebishwhip/laradocs 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 petebishwhip/laradocs 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 petebishwhip/laradocs 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
Bookdown.io With Bootswatch Styles And Prism Syntax Highlighting
Laravel package that generates RESTful API documentation in Markdown based on PHPDoc.
Adds more BBCode
Api documentation generator for Laravel 5
Replacement for Swagger. It is built for Laravel
统计信息
- 总下载量: 5.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 87
- 点击次数: 39
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-03