wamesk/docs 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

wamesk/docs

最新稳定版本:1.0.0

Composer 安装命令:

composer require wamesk/docs

包简介

Developer documentation viewer

README 文档

README

Laravel package that serves markdown files from your docs/ directory as a styled in-app documentation portal, with built-in authorization and optional API reference support via dedoc/scramble.

Requirements

  • PHP 8.2+
  • Laravel 11+
  • dedoc/scramble ^0.13

Installation

composer require wamesk/docs

The service provider is registered automatically via Laravel's package discovery.

Setup

1. Create an application service provider

Create app/Providers/DocsServiceProvider.php by extending the abstract base class:

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Gate;
use Wame\Docs\DocsApplicationServiceProvider;

class DocsServiceProvider extends DocsApplicationServiceProvider
{
    protected function gate(): void
    {
        Gate::define('viewDocs', function ($user) {
            return $user->is_admin;
        });
    }
}

2. Register the provider

Add it to bootstrap/providers.php:

return [
    // ...
    App\Providers\DocsServiceProvider::class,
];

3. Publish the config (optional)

php artisan vendor:publish --tag=docs-config

This publishes config/docs.php where you can customize the middleware stack:

return [
    'middleware' => [
        'web',
        \Wame\Docs\Http\Middleware\Authorize::class,
    ],
];

Usage

Place markdown files in your project's docs/ directory:

docs/
├── getting-started.md
├── installation.md
└── configuration.md

The package automatically discovers all .md files and lists them on the index page. The first heading (# Title) in each file is used as its display name.

Routes

Method URI Description
GET /docs Index — list of all documentation files
GET /docs/{file} Renders a single markdown file

Authorization

Access is controlled via the viewDocs Laravel Gate. Unauthenticated users are redirected to /. Authenticated users without permission receive a 403.

Override the gate() method in your application service provider to define who can access the docs:

protected function gate(): void
{
    Gate::define('viewDocs', function ($user) {
        return in_array($user->email, config('docs.allowed_emails', []));
    });
}

For full control over the authorization flow, override authorization():

protected function authorization(): void
{
    $this->gate();

    Docs::auth(function (Request $request): bool {
        return Gate::check('viewDocs', [$request->user()]);
    });
}

API Reference

The /docs/api route is reserved for API documentation rendered by dedoc/scramble. Configure Scramble separately in config/scramble.php.

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固