定制 blackpig-creatif/grimoire 二次开发

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

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

blackpig-creatif/grimoire

Composer 安装命令:

composer require blackpig-creatif/grimoire

包简介

In-panel documentation for FilamentPHP applications

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

In-panel documentation for FilamentPHP v5 applications.

Grimoire lets you embed rich, versioned documentation directly inside your Filament admin panel. Organise content into Tomes (top-level books) and Chapters (individual pages), author in Markdown with YAML frontmatter, and edit chapters inline without leaving the panel.

Requirements

  • PHP 8.2+
  • Laravel 11 or 12
  • Filament v5

Installation

composer require blackpig-creatif/grimoire

Publish the config (optional):

php artisan vendor:publish --tag="grimoire-config"

Plugin Registration

Register the plugin in your Filament panel provider:

use BlackpigCreatif\Grimoire\GrimoirePlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            GrimoirePlugin::make()
                ->navigationGroup('Help')    // optional — defaults to 'Help'
                ->withDocs(),                // optional — enables Grimoire's own built-in docs
        ]);
}

Registering a Tome

A Tome is a top-level documentation section. Register one in your AppServiceProvider::boot():

use BlackpigCreatif\Grimoire\Facades\Grimoire;

Grimoire::registerTome(
    id: 'my-docs',
    label: 'My Documentation',
    icon: 'heroicon-o-book-open',
    path: resource_path('grimoire/my-docs'),
    clusterClass: \App\Filament\Grimoire\Clusters\MyDocsCluster::class,
);

Then scaffold the required Filament stubs:

php artisan grimoire:make-tome my-docs "My Documentation"

Adding Chapters

php artisan grimoire:make-chapter my-docs my-chapter "My Chapter Title"

This generates a Filament page stub and a Markdown file at resources/grimoire/my-docs/my-chapter.md. Add content with YAML frontmatter:

---
title: My Chapter
order: 1
icon: heroicon-o-document-text
---

# My Chapter

Content goes here.

Extending a Tome

Override or add chapters to any Tome (including vendor Tomes) from your app:

Grimoire::extendTome(
    id: 'my-docs',
    path: resource_path('grimoire/my-docs-local'),
);

Local chapters take priority over vendor chapters on slug collision — useful for overriding package documentation with app-specific notes.

Permissions

Access to view and edit documentation is controlled via config/grimoire.php:

'permissions' => [
    'view' => null,   // null = allow all authenticated users (default)
    'edit' => null,   // null = deny all (default)
],

Each key accepts one of the following:

null (default behaviour)

  • view: all authenticated users may read chapters
  • edit: no one may edit chapters

A Laravel Gate ability name

'permissions' => [
    'view' => 'view-docs',
    'edit' => 'edit-docs',
],

Define the ability in AuthServiceProvider (or a dedicated GrimoirePolicy):

Gate::define('view-docs', fn (User $user) => $user->hasRole('staff'));
Gate::define('edit-docs', fn (User $user) => $user->hasRole('admin'));

A Class@method string

'permissions' => [
    'view' => \App\Policies\GrimoirePolicy::class . '@view',
    'edit' => \App\Policies\GrimoirePolicy::class . '@edit',
],

The method receives the authenticated user as its only argument and must return a boolean.

A closure (local development only)

Closures work when config is not cached, making them convenient for local development. They cannot be used in production with php artisan config:cache.

'permissions' => [
    'view' => fn ($user) => true,
    'edit' => fn ($user) => $user->is_admin,
],

Inline Editing

Authenticated users with edit permission can edit chapter content directly in the panel. Click Edit on any chapter page to switch to an inline editor with a Markdown editor for content and a YAML editor for frontmatter.

Locale Support

Grimoire supports two locale strategies for multilingual documentation. Configure in config/grimoire.php:

'locale_strategy' => 'suffix',   // 'suffix' or 'directory'
'fallback_locale'  => 'en',

Suffix strategy — place locale variants alongside the default file:

my-chapter.md       ← locale-neutral fallback
my-chapter.fr.md    ← French
my-chapter.de.md    ← German

Directory strategy — organise by locale subdirectory:

my-chapter.md
fr/my-chapter.md
de/my-chapter.md

Grimoire resolves files in order: current locale → fallback locale → locale-neutral.

Built-in Self-Documentation

Enable Grimoire's own documentation Tome inside your panel with ->withDocs():

GrimoirePlugin::make()->withDocs()

// Or conditionally — e.g. local environment only:
GrimoirePlugin::make()->withDocs(fn ($user) => app()->isLocal())

Caching

For production, cache the navigation tree:

php artisan grimoire:cache
php artisan grimoire:clear-cache

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.

blackpig-creatif/grimoire 适用场景与选型建议

blackpig-creatif/grimoire 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 100 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「documentation」 「laravel」 「Grimoire」 「filament」 「filament-plugin」 「filamentphp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 blackpig-creatif/grimoire 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 blackpig-creatif/grimoire 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-23