xoshbin/pertuk
Composer 安装命令:
composer require xoshbin/pertuk
包简介
A powerful Laravel documentation package with multi-language support, markdown processing, and beautiful UI
README 文档
README
Pertuk is a powerful Laravel documentation package that provides a complete documentation system with multi-language support, markdown processing, search functionality, and a beautiful, responsive UI.
Features
- 📖 Premium Markdown: Full CommonMark and GitHub Flavored Markdown support
- 🎨 Shiki Syntax Highlighting: Server-side, VS-Code quality syntax highlighting
- 🌍 Multi-Language Support: Built-in support for multiple locales with RTL handling
- 🪴 Root Locale: Serve a primary language at the docs root with no URL prefix (VitePress/Starlight style)
- 🔢 Versioning Support: Explicit version configuration with a built-in version picker
- 🐙 GitHub Source: Render docs directly from any GitHub repository
- 🔍 Deep Local Search: Full-content indexing via MiniSearch with relevancy scoring
- 🧩 Interactive Components: Built-in support for Tabs and Accordions in Markdown
- 🎨 Modern UI: Responsive design with interactive sidebar and dark mode
- 📱 Mobile Friendly: Optimized for all device sizes
- 🗂️ Auto Table of Contents: Automatic TOC generation from headings
- 💾 Intelligent Caching: High-performance document rendering and caching
- 🧭 Breadcrumbs: Automatic breadcrumb navigation
- 🏷️ Front Matter Support: YAML front matter for metadata
- 💡 Admonitions: Support for tip, warning, and danger callouts
- 🚀 Pre-rendering: Artisan command to pre-render documentation for maximum speed
Quick Start
- Install the package:
composer require xoshbin/pertuk
- Publish the assets (JS and CSS):
php artisan vendor:publish --tag="pertuk-assets"
- (Optional) Publish the config:
php artisan vendor:publish --tag="pertuk-config"
-
Create your docs directory and add a markdown file.
-
Visit your docs at
/docs.
- Customization: Publish the views to customize the layout and markup:
php artisan vendor:publish --tag="pertuk-views"
- (Optional) Pre-render documentation for performance:
php artisan pertuk:build
Configuration
return [ // Root folder for documentation files (local source). 'root' => base_path('docs'), // Source driver: 'local' (default) or 'github'. 'source' => env('PERTUK_SOURCE', 'local'), // Per-driver configuration. 'sources' => [ 'local' => [ 'root' => env('PERTUK_DOCS_LOCAL_ROOT'), ], 'github' => [ 'repo' => env('PERTUK_DOCS_REPO'), 'branch' => env('PERTUK_DOCS_BRANCH', 'main'), 'path' => env('PERTUK_DOCS_PATH', 'docs'), 'token' => env('PERTUK_DOCS_TOKEN'), 'cache_path' => storage_path('app/pertuk/github'), ], ], // Locale configuration — mirrors VitePress/Starlight conventions. // The 'root' key designates the primary locale whose files live flat // at the docs root with no URL prefix. Secondary locales keep /{code}/. // Omit 'root' to use classic locale-prefixed mode (docs/en/, docs/ar/). 'locales' => [ 'root' => ['label' => 'English', 'lang' => 'en', 'dir' => 'ltr'], 'ar' => ['label' => 'العربية', 'lang' => 'ar', 'dir' => 'rtl'], 'ckb' => ['label' => 'کوردی (سۆرانی)', 'lang' => 'ckb', 'dir' => 'rtl'], ], // Explicit version list. Empty = no versioning. // e.g. ['v1.0', 'v2.0'] 'versions' => [], // Default sort order when front matter 'order' is missing. 'default_order' => 1000, // Excluded files or folders (relative to root) for file listing. 'exclude_directories' => [ '.DS_Store', 'README.md', ], // Cache TTL (seconds) for parsed HTML & metadata. 'cache_ttl' => 3600, // Enable or disable the documentation system. 'enabled' => true, // Route prefix for documentation. 'route_prefix' => 'docs', // Route name prefix. 'route_name_prefix' => 'pertuk.docs.', // Route middleware. 'middleware' => ['web'], // GitHub Repo & Branch for "Edit on GitHub" links. 'github_repo' => env('PERTUK_GITHUB_REPO', 'username/repo'), 'github_branch' => env('PERTUK_GITHUB_BRANCH', 'main'), 'github_path' => null, // Assets directory (relative to documentation root). 'assets_path' => 'assets', // External links. 'github_url' => env('PERTUK_GITHUB_URL', ''), 'discord_url' => env('PERTUK_DISCORD_URL', ''), ];
Directory Structures
Root locale (flat) — recommended for single-language or GitHub-sourced repos
Inspired by VitePress and Starlight. One locale is designated root in config — its files live directly at the docs root with no subdirectory or URL prefix. Secondary locales keep their /{code}/ prefix.
docs/
├── explanation/
│ └── introduction.md → /docs/explanation/introduction
├── how-to/
│ └── publishing.md → /docs/how-to/publishing
├── tutorials/
│ └── quick-start.md → /docs/tutorials/quick-start
└── ar/
└── explanation/
└── introduction.md → /docs/ar/explanation/introduction
Config:
'locales' => [ 'root' => ['label' => 'English', 'lang' => 'en', 'dir' => 'ltr'], 'ar' => ['label' => 'العربية', 'lang' => 'ar', 'dir' => 'rtl'], ],
Classic locale-prefixed — all locales in subdirectories
Omit the root key. Every locale, including the primary one, lives in its own subdirectory. This is the legacy behaviour and continues to work unchanged.
docs/
├── en/
│ └── getting-started.md → /docs/en/getting-started
└── ar/
└── getting-started.md → /docs/ar/getting-started
Config:
'locales' => [ 'en' => ['label' => 'English', 'lang' => 'en', 'dir' => 'ltr'], 'ar' => ['label' => 'العربية', 'lang' => 'ar', 'dir' => 'rtl'], ],
Versioned structure
Add version directories above the locale layout. Declare versions explicitly in config — no automatic directory scanning.
docs/
├── v1.0/
│ ├── getting-started.md → /docs/v1.0/getting-started (root locale)
│ └── ar/
│ └── getting-started.md → /docs/v1.0/ar/getting-started
└── v2.0/
└── getting-started.md → /docs/v2.0/getting-started
Config:
'locales' => [ 'root' => ['label' => 'English', 'lang' => 'en', 'dir' => 'ltr'], 'ar' => ['label' => 'العربية', 'lang' => 'ar', 'dir' => 'rtl'], ], 'versions' => ['v1.0', 'v2.0'],
Monolingual (single language, no locale UI)
Configure only a root locale with no secondary entries. The language picker is hidden automatically.
docs/
├── getting-started.md → /docs/getting-started
└── reference/
└── api.md → /docs/reference/api
Config:
'locales' => [ 'root' => ['label' => 'English', 'lang' => 'en', 'dir' => 'ltr'], ], 'versions' => [],
GitHub Source
Pertuk can render markdown stored in a GitHub repository instead of the local filesystem. Set PERTUK_SOURCE=github and configure the repo, branch, and path. The package syncs the full directory tree into storage/app/pertuk/github/ during pertuk:build and falls back to on-demand single-file fetches at runtime.
PERTUK_SOURCE=github PERTUK_DOCS_REPO=Xoshbin/asyar-launcher PERTUK_DOCS_BRANCH=main PERTUK_DOCS_PATH=docs # Optional — required for private repos, recommended to avoid the 60/hr anonymous rate limit. PERTUK_DOCS_TOKEN=ghp_xxx
The GitHub source works with all directory structures above — including root locale (flat) layouts. Run php artisan pertuk:build as part of your deploy to sync changes.
Migrating from the old locale config
If you are upgrading from a version that used supported_locales, default_locale, rtl_locales, and locale_labels, replace them with the unified locales map. No files need to move if you omit the root key.
// Before 'supported_locales' => ['en', 'ar'], 'default_locale' => 'en', 'rtl_locales' => ['ar'], 'locale_labels' => ['en' => 'English', 'ar' => 'العربية'], // After (classic prefix mode — no files to move) 'locales' => [ 'en' => ['label' => 'English', 'lang' => 'en', 'dir' => 'ltr'], 'ar' => ['label' => 'العربية', 'lang' => 'ar', 'dir' => 'rtl'], ], 'versions' => [],
Also replace exclude_versions with an explicit versions array — list only the versions you want to expose.
If you published the vendor views (php artisan vendor:publish --tag="pertuk-views"), re-publish them to get the updated templates, or replace any route('pertuk.docs.show', ['locale' => ..., 'slug' => ...]) calls with \Xoshbin\Pertuk\Support\PertukUrl::doc($slug).
Front Matter
--- title: "Getting Started" order: 1 --- # Getting Started Your content here...
Interactive Components (Alpine.js)
Tabs
<x-pertuk-tabs> <x-pertuk-tab name="PHP"> ```php echo "Hello World";
console.log("Hello World");```
Accordion
<x-pertuk-accordion> <x-pertuk-accordion-item title="Can I customize the design?"> Yes! Publish the views to match your brand. </x-pertuk-accordion-item> </x-pertuk-accordion>
Admonitions
::: tip This is a helpful tip. ::: ::: warning Be careful with this setting. ::: ::: danger This action cannot be undone. :::
Assets & Images
Place images in an assets/ directory at the docs root and reference them with relative paths:

Pertuk rewrites these paths to /docs/assets/filename.png automatically.
Directory conflict warning: Do not create a physical public/docs directory. In Nginx, physical directories take precedence over Laravel routes, causing 403 Forbidden errors.
Performance
Pre-render all documentation to cache during deployment:
php artisan pertuk:build
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
xoshbin/pertuk 适用场景与选型建议
xoshbin/pertuk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 864 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 09 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「documentation」 「markdown」 「docs」 「laravel」 「multi-language」 「Xoshbin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 xoshbin/pertuk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 xoshbin/pertuk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 xoshbin/pertuk 相关的其它包
同方向 / 同关键字的高下载量 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
统计信息
- 总下载量: 864
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-09
