定制 smmahfujurrahman/docgen 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

smmahfujurrahman/docgen

Composer 安装命令:

composer require smmahfujurrahman/docgen

包简介

A beautiful Laravel package for viewing Markdown documentation with GitHub-style rendering

README 文档

README

Latest Version on Packagist Total Downloads

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

  1. Install the package (see above)

  2. Publish the assets:

    php artisan vendor:publish --tag=docgen
  3. Access your documentation:

    http://your-app.test/documentation
    

That's it! You'll see the welcome page with dummy documentation.

Adding Your Documentation

  1. Navigate to the docs folder in your Laravel project root
  2. Add your .md (Markdown) files
  3. 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 page
  • docs-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:

  1. File Type Validation: Only .md files are accessible
  2. Directory Traversal Protection: Prevents ../ attacks
  3. Path Validation: Uses realpath() for secure path resolution
  4. 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)
![Image](image.jpg)

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) or Cmd+K (Mac)
  • Press Escape to 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:

  1. Add to your Laravel app's composer.json:
{
    "repositories": [
        {
            "type": "path",
            "url": "./packages/smmahfujurrahman/docgen"
        }
    ]
}
  1. 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.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

The MIT License (MIT). Please see LICENSE for more information.

👤 Author

S. M. Mahfujur Rahman

🙏 Credits

💡 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 smmahfujurrahman/docgen 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 32
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 23
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Blade

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-08