定制 osenco/filament-modules 二次开发

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

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

osenco/filament-modules

Composer 安装命令:

composer require osenco/filament-modules

包简介

Organize your Filament Code into modules using nwidart/laravel-modules

README 文档

README

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

NOTE: This documentation is for version 4.x of the package, which only supports Laravel 11 and nwidart/laravel-modules ^11. If you are using Laravel 10, please refer to the 3.x documentation.

image

This package brings the power of modules to Laravel Filament. It allows you to organize your filament code into fully autonomous modules that can be easily shared and reused across multiple projects. With this package, you can turn each of your modules into a fully functional Filament Plugin with its own resources, pages, widgets, components and more. What's more, you don't even need to register each of these plugins in your main Filament Panel. All you need to do is register the ModulesPlugin in your panel, and it will take care of the rest for you.

This package is simple a wrapper of nwidart/laravel-modules package to make it work with Laravel Filament.

Features

  • A command to prepare your module for Filament
  • A command to create a Filament Cluster in your module
  • A command to create additional Filament Plugins in your module
  • A command to create a new Filament resource in your module
  • A command to create a new Filament page in your module
  • A command to create a new Filament widget in your module
  • Organize your admin panel into Cluster, one for each supported module.

Requirements

v4.x of this package requires the following dependencies:

  • Laravel 11.x or higher
  • Filament 3.x or higher
  • PHP 8.2 or higher
  • nwidart/laravel-modules 11.x

If you are using Laravel 10 please use version 3.x instead.

Installation

You can install the package via composer:

composer require coolsam/modules:^4

This will automatically install nwidart/laravel-modules: ^11 as well. Make sure you go through the documentation to understand how to use the package and to configure it properly before proceeding.

You can publish the config file with:

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

Alternatively, just run the installation command and follow the prompts:

php artisan module:filament:install

Configuration

After publishing the config file, you can configure the package to your liking. The configuration file is located at config/filament-modules.php. The following can be adjusted in the configuration file:

  • auto-register-plugins: If set to true, the package will automatically register all the plugins in your modules. Otherwise, you will need to register each plugin manually in your Filament Panel.
  • clusters.enabled: If set to true, a cluster will be created in each module during the module:filament:install command and all filament files for that module may reside inside that cluster. Otherwise, filament files will reside in Filament/Resources, Filament/Pages, Filament/Widgets, etc.
  • clusters.use-top-navigation: If set to true, the top navigation will be used to navigate between clusters while the actual links will be loaded as a side sub-navigation. In my opinion, this improves UX. Otherwise, the package will honor the configuration that you have in your panel.

Usage

Register the plugin

The package comes with a ModulesPlugin that you can register in your Filament Panel. This plugin will automatically load all the modules in your application and register them as Filament plugins. In order to achieve this, you need to register the ModulesPlugin in your panel of choice (e.g. Admin Panel) like so:

// e.g. in App\Providers\Filament\AdminPanelProvider.php
 
use Coolsam\Modules\ModulesPlugin;
public function panel(Panel $panel): Panel
{
    return $panel
        ...
        ->plugin(ModulesPlugin::make());
}

That's it! now you are ready to start creating some filament code in your module of choice!

Installing Filament in a module

If you don't have a module already, you can generate one using the module:make command like so:

php artisan module:make MyModule

Next, run the module:filament:install command to generate the necessary Filament files and directories in your module:

php artisan module:filament:install MyModule

This will guide you interactively on whether you want to organize your code in clusters, and whether you would like to create a default cluster. At the end of this installation, you will have the following structure in your module:

  • Modules
    • MyModule
      • app
        • Filament
          • Clusters
            • MyModule
              • Pages
              • Resources
              • Widgets
            • MyModule.php
          • Pages
          • Resources
          • Widgets
          • MyModulePlugin.php

As you can see, there are two main files generated: The plugin class and optionally the cluster class. After generation, you are free to make any modifications to these classes as you may see fit.

The plugin will be loaded automatically unless the configuration is set otherwise. As a result, it will also load all its clusters automatically.

Your module is now ready to be used in your Filament Panel. Use the following commands during development to generate new resources, pages, widgets and clusters in your module:

Creating a new resource

php artisan module:make:filament-resource

Follow the interactive prompts to create a new resource in your module.

Creating a new page

php artisan module:make:filament-page

Follow the interactive prompts to create a new page in your module.

###Creating a new widget

php artisan module:make:filament-widget

Follow the interactive prompts to create a new widget in your module.

Creating a new cluster

php artisan module:make:filament-cluster

Follow the interactive prompts to create a new cluster in your module.

Creating a new plugin

php artisan module:make:filament-plugin

Follow the interactive prompts to create a new plugin in your module.

Create a new Filament Theme

php artisan module:make:filament-theme

Follow the instructions to protect your resources and pages if your module is not active.

use Coolsam\Modules\Resource;

use the above resource class instead of use Filament/Resources/Resource; into your resource class file to protect your resources.

use Coolsam\Modules\Page;

use the above page class instead of use Filament/Pages/Page; into your page class file to protect your pages.

use Coolsam\Modules\TableWidget;

use the above page class instead of use Filament/Pages/TableWidget; into your widget class file to protect your TableWidget.

use Coolsam\Modules\ChartWidget;

use the above page class instead of use Filament/Pages/ChartWidget; into your widget class file to protect your ChartWidget.

use Coolsam\Modules\StatsOverviewWidget;

use the above page class instead of use Filament/Pages/StatsOverviewWidget; into your widget class file to protect your StatsOverviewWidget.

use CanAccessTrait;

use the above trait directly into your resource and page class file to protect your resources and pages.

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.

osenco/filament-modules 适用场景与选型建议

osenco/filament-modules 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 osenco/filament-modules 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-24