smmahfujurrahman/docgen
Composer 安装命令:
composer require smmahfujurrahman/docgen
包简介
A beautiful Laravel package for viewing Markdown documentation with GitHub-style rendering
README 文档
README
A beautiful Laravel package for viewing Markdown documentation with GitHub-style rendering, search functionality, and zero configuration.
✨ Features
- 📖 Beautiful GitHub-Style Rendering - Professional documentation view
- 🔍 Real-time Search - Find docs instantly with Ctrl+K
- 🎨 Syntax Highlighting - Code blocks with Highlight.js
- 📱 Responsive Design - Works on all devices
- 🔒 Secure - Protection against directory traversal
- 📋 Copy Code Buttons - One-click code copying
- ⚡ Zero Configuration - Works out of the box
- 🗂️ Folder Organization - Automatic categorization
- 🎯 SEO Friendly - Proper heading structure
📋 Requirements
- PHP 8.1 or higher
- Laravel 10.x or ^11.x
- Composer
🚀 Installation
Install the package via Composer:
composer require smmahfujurrahman/docgen
The package will automatically register its service provider.
📦 Publishing Assets
Publish all assets at once:
php artisan vendor:publish --tag=docgen
Or publish specific assets:
# Publish configuration php artisan vendor:publish --tag=docgen-config # Publish routes php artisan vendor:publish --tag=docgen-routes # Publish views php artisan vendor:publish --tag=docgen-views # Publish dummy documentation php artisan vendor:publish --tag=docgen-docs
🎯 Usage
Quick Start
-
Install the package (see above)
-
Publish the assets:
php artisan vendor:publish --tag=docgen
-
Access your documentation:
http://your-app.test/documentation
That's it! You'll see the welcome page with dummy documentation.
Adding Your Documentation
- Navigate to the
docsfolder in your Laravel project root - Add your
.md(Markdown) files - Refresh the documentation page
Example structure:
docs/
├── README.md
├── installation.md
├── api/
│ ├── authentication.md
│ └── endpoints.md
└── guides/
├── getting-started.md
└── deployment.md
Linking Routes in Your App
After publishing, update your routes/web.php to include the documentation routes:
// At the end of routes/web.php if (file_exists(base_path('routes/docs.php'))) { require base_path('routes/docs.php'); }
Or if you want to customize, you can manually define routes using the config:
Route::get('/docs', function () { // Your custom implementation });
⚙️ Configuration
The configuration file will be published to config/docgen.php:
return [ // Route prefix for documentation (default: 'documentation') 'route_prefix' => env('DOCGEN_ROUTE_PREFIX', 'documentation'), // Directory where markdown files are stored (default: 'docs') 'docs_path' => env('DOCGEN_DOCS_PATH', 'docs'), // Auto-register routes (default: true) 'auto_register_routes' => env('DOCGEN_AUTO_ROUTES', true), // CommonMark configuration 'commonmark' => [ 'html_input' => 'allow', 'allow_unsafe_links' => false, ], ];
Environment Variables
Add these to your .env file to customize:
DOCGEN_ROUTE_PREFIX=documentation DOCGEN_DOCS_PATH=docs DOCGEN_AUTO_ROUTES=true
🎨 Customization
Customizing Views
Publish the views and modify them:
php artisan vendor:publish --tag=docgen-views
Views will be copied to resources/views/documentations/:
docs-index.blade.php- Documentation index pagedocs-viewer.blade.php- Individual document viewer
Customizing Styles
Edit the published views to change colors, fonts, or layout. The views use inline CSS for easy customization.
Custom Routes
If you want full control over routes, set auto_register_routes to false in config and define your own routes:
use League\CommonMark\CommonMarkConverter; Route::get('/my-docs', function () { // Your custom documentation logic });
🔒 Security Features
DocGen includes built-in security:
- File Type Validation: Only
.mdfiles are accessible - Directory Traversal Protection: Prevents
../attacks - Path Validation: Uses
realpath()for secure path resolution - Configurable Paths: Restrict docs to specific directories
📖 Markdown Support
DocGen supports full Markdown syntax:
Basic Formatting
# Heading 1 ## Heading 2 ### Heading 3 **Bold Text** *Italic Text* ~~Strikethrough~~ [Link](https://example.com) 
Code Blocks
```php <?php echo "Hello, World!";
### Tables
```markdown
| Column 1 | Column 2 |
|----------|----------|
| Data 1 | Data 2 |
Lists
- Unordered item - Another item 1. Ordered item 2. Another item
Blockquotes
> This is a blockquote
🎯 Features in Detail
Search Functionality
- Real-time search as you type
- Searches both filenames and content titles
- Keyboard shortcut:
Ctrl+K(Windows/Linux) orCmd+K(Mac) - Press
Escapeto clear search
Syntax Highlighting
Powered by Highlight.js with support for:
- PHP, JavaScript, Python, Ruby, Java, C++, and more
- Auto-detection of languages
- GitHub color scheme
Copy Code Buttons
- Appears on hover over code blocks
- One-click copying to clipboard
- Visual feedback on successful copy
Responsive Design
- Mobile-first approach
- Tablet-optimized layouts
- Desktop full-feature experience
🛠️ Development
Local Package Development
To test the package locally before publishing:
- Add to your Laravel app's
composer.json:
{
"repositories": [
{
"type": "path",
"url": "./packages/smmahfujurrahman/docgen"
}
]
}
- Require the package:
composer require smmahfujurrahman/docgen:@dev
Running Tests
composer test
📝 Changelog
Please see CHANGELOG for more information on what has changed recently.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
📄 License
The MIT License (MIT). Please see LICENSE for more information.
👤 Author
S. M. Mahfujur Rahman
- GitHub: @MahfujuRahman
- Email: mahfujur.dev@gmail.com
🙏 Credits
- Built with Laravel
- Markdown parsing by CommonMark
- Syntax highlighting by Highlight.js
- Icons by Font Awesome
- Styling inspired by GitHub
💡 Support
If you find this package helpful, please consider:
- ⭐ Starring the repository
- 🐛 Reporting bugs
- 💡 Suggesting new features
- 📝 Improving documentation
Made with ❤️ by S. M. Mahfujur Rahman
smmahfujurrahman/docgen 适用场景与选型建议
smmahfujurrahman/docgen 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 32 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「documentation」 「markdown」 「docs」 「laravel」 「Viewer」 「ajmain」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 smmahfujurrahman/docgen 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 smmahfujurrahman/docgen 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 smmahfujurrahman/docgen 相关的其它包
同方向 / 同关键字的高下载量 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
统计信息
- 总下载量: 32
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-08