pixielity/laravel-sdui
Composer 安装命令:
composer require pixielity/laravel-sdui
包简介
Server-Driven UI Schema Extractors for Filament
README 文档
README
SDUI Module - Schema Extractors for Filament
This module provides Schema Extractors that convert Filament components (Forms, Tables, Actions, Widgets) into JSON schemas for Server-Driven UI applications.
Architecture
Instead of rebuilding Filament from scratch, this module:
- ✅ Uses Filament directly for all UI components
- ✅ Extracts schemas from Filament components
- ✅ Provides JSON APIs for mobile/frontend clients
- ✅ Caches extracted schemas for performance
Filament Resources → Schema Extractors → JSON API → Mobile/Frontend
Installation
- Register the service provider in
config/app.php:
'providers' => [
// ...
Modules\SDUI\Providers\SDUIServiceProvider::class,
],
- Publish the configuration:
php artisan vendor:publish --tag=sdui-config
Usage
1. Define Filament Resources (Standard Filament)
// app/Filament/Resources/PostResource.php
class PostResource extends Resource
{
public static function form(Form $form): Form
{
return $form->schema([
TextInput::make('title')->required(),
Textarea::make('content'),
Select::make('status')->options([
'draft' => 'Draft',
'published' => 'Published',
]),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('title')->searchable(),
BadgeColumn::make('status'),
TextColumn::make('created_at')->dateTime(),
])
->actions([
EditAction::make(),
DeleteAction::make(),
])
->bulkActions([
DeleteBulkAction::make(),
]);
}
}
2. Extract Schemas via API
The module automatically provides API endpoints:
# List all resources
GET /api/sdui/resources
# Get complete resource schema
GET /api/sdui/resources/posts
# Get form schema (create page)
GET /api/sdui/resources/posts/form/create
# Get form schema (edit page)
GET /api/sdui/resources/posts/form/edit
# Get table schema
GET /api/sdui/resources/posts/table
# Invalidate cache
POST /api/sdui/cache/invalidate
3. Use Extractors Programmatically
use Modules\SDUI\Contracts\FormSchemaExtractorInterface;
use Modules\SDUI\Contracts\TableSchemaExtractorInterface;
use Modules\SDUI\Contracts\ResourceSchemaExtractorInterface;
class MyController extends Controller
{
public function __construct(
protected ResourceSchemaExtractorInterface $extractor
) {}
public function getSchema()
{
// Extract complete resource schema
$schema = $this->extractor->extractResource(PostResource::class);
// Extract just the form
$formSchema = $this->extractor->extractCreatePage(PostResource::class);
// Extract just the table
$tableSchema = $this->extractor->extractListPage(PostResource::class);
return response()->json($schema);
}
}
Available Extractors
FormSchemaExtractor
Extracts schemas from Filament Forms:
- All field types (TextInput, Select, Textarea, etc.)
- Validation rules
- Field relationships
- Reactive dependencies
TableSchemaExtractor
Extracts schemas from Filament Tables:
- All column types (TextColumn, BadgeColumn, etc.)
- Filters
- Actions and bulk actions
- Table configuration (pagination, search, sort)
ActionSchemaExtractor
Extracts schemas from Filament Actions:
- Action properties (label, icon, color)
- Modal configuration
- Confirmation dialogs
- Action forms
ResourceSchemaExtractor
Extracts complete resource schemas:
- Form schemas (create, edit)
- Table schemas (list)
- Navigation configuration
- All resource pages
WidgetSchemaExtractor
Extracts schemas from Filament Widgets:
- Stats widgets
- Chart widgets
- Table widgets
- Custom widgets
Schema Registry
The Schema Registry caches extracted schemas for performance:
use Modules\SDUI\Contracts\SchemaRegistryInterface;
$registry = app(SchemaRegistryInterface::class);
// Get cached schema
$schema = $registry->get('posts', 'form');
// Store schema
$registry->set('posts', 'form', $schema);
// Invalidate cache
$registry->invalidate('posts');
$registry->invalidateAll();
// Disable caching temporarily
$registry->withoutCache()->get('posts', 'form');
Configuration
Edit config/sdui.php:
return [
'cache' => [
'enabled' => true,
'ttl' => 3600, // 1 hour
],
'extraction' => [
'include_hidden_fields' => false,
'include_validation_rules' => true,
'include_relationships' => true,
],
'security' => [
'require_authentication' => false,
'allowed_resources' => [], // Empty = all allowed
],
];
Example JSON Response
{
"data": {
"type": "resource",
"name": "posts",
"label": "Post",
"pluralLabel": "Posts",
"pages": {
"list": {
"type": "table",
"columns": [
{
"type": "text",
"name": "title",
"label": "Title",
"searchable": true,
"sortable": true
},
{
"type": "badge",
"name": "status",
"label": "Status",
"colors": {
"draft": "gray",
"published": "success"
}
}
],
"actions": [
{
"type": "action",
"name": "edit",
"label": "Edit",
"icon": "heroicon-o-pencil"
}
]
},
"create": {
"type": "create",
"form": {
"type": "form",
"fields": [
{
"type": "text",
"name": "title",
"label": "Title",
"required": true,
"validation": ["required", "string", "max:255"]
},
{
"type": "textarea",
"name": "content",
"label": "Content"
}
]
}
}
}
}
}
Benefits
- No Duplication: Use Filament directly, no need to rebuild components
- Always Up-to-Date: Automatically get Filament improvements
- Single Source of Truth: Define UI once in Filament
- Performance: Cached schemas for fast API responses
- Flexibility: Extract any Filament component to JSON
- Type Safety: Full PHP type hints and interfaces
Testing
# Test schema extraction
php artisan test --filter=SchemaExtractorTest
# Test API endpoints
php artisan test --filter=SchemaControllerTest
License
MIT
pixielity/laravel-sdui 适用场景与选型建议
pixielity/laravel-sdui 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「schema」 「Forms」 「laravel」 「tables」 「filament」 「sdui」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pixielity/laravel-sdui 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pixielity/laravel-sdui 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pixielity/laravel-sdui 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
ConfirmationField is a form field for Atk14 applications. It's like the BooleanField (checkbox) but the ConfirmationField must be ticked.
Field for number with restricted count of digits and decimal places
Extension for Opis JSON Schema
EAV modeling package for Eloquent and Laravel.
serialize Symfony Forms into JSON schema
HTML and form generation
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-09