pxlrbt / laravel-docs
Render markdown documentation inside Laravel with a modern VitePress-inspired layout.
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 1
pkg:composer/pxlrbt/laravel-docs
Requires
- php: ^8.2
- illuminate/contracts: ^11.0|^12.0
- league/commonmark: ^2.5
- spatie/laravel-package-tools: ^1.16
- symfony/yaml: ^7.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.0
- orchestra/testbench: ^10.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
This package is auto-updated.
Last update: 2026-02-10 16:35:17 UTC
README
Render markdown documentation inside Laravel.
Requirements
- PHP 8.2+
- Laravel 11 or 12
Installation
composer require pxlrbt/laravel-docs
Publish the config and assets:
php artisan vendor:publish --tag=docs-config php artisan vendor:publish --tag=docs-assets
Usage
Place markdown files in the configured root directory (default: docs/). Each file needs YAML frontmatter:
--- title: "Getting Started" description: "An introduction to the app" group: "Basics" order: 0 --- Your markdown content here.
Pages are accessible at /{url_prefix}/{slug}, e.g. /docs/getting-started.
Configuration
The config file (config/docs.php) supports multiple doc instances as a keyed array:
return [ 'default' => [ 'root' => env('DOCS_ROOT', 'docs'), // Markdown files directory 'url_prefix' => env('DOCS_URL_PREFIX', 'docs'),// URL path prefix 'layout' => null, // Blade layout component to wrap content 'requires_auth' => false, // Require authentication 'auth_middleware' => ['auth'], // Middleware when auth is required 'can_access_docs' => null, // Closure for fine-grained access control 'has_navigation' => true, // Show sidebar navigation 'has_sidebar' => true, // Show table of contents 'has_pagination' => true, // Show prev/next page links ], ];
Multiple Instances
Define additional instances to serve separate doc sections with different configs:
return [ 'default' => [ 'root' => 'docs', 'url_prefix' => 'docs', ], 'api' => [ 'root' => 'docs/api', 'url_prefix' => 'api-docs', 'requires_auth' => true, ], ];
Access Control
Use the can_access_docs callback for fine-grained access control:
'can_access_docs' => function ($user) { return $user?->isAdmin(); },
Custom Layout
Wrap the docs in your app's layout by setting the layout option to a Blade component name:
'layout' => 'layouts.app',
When no layout is set, docs render as a standalone page with their own styles.
Features
- GitHub-flavored markdown (tables, strikethrough, etc.)
- Auto-generated table of contents from h2/h3 headings
- Heading permalink anchors
- Sidebar navigation grouped by frontmatter
group - Prev/next page pagination
- Responsive design (mobile, tablet, desktop)
- Sidebar caching for performance
- Directory traversal protection
License
MIT