定制 iamgerwin/filament-page-manager 二次开发

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

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

iamgerwin/filament-page-manager

Composer 安装命令:

composer require iamgerwin/filament-page-manager

包简介

A comprehensive page management system for Filament v4 with templates, regions, SEO, and multilingual support

README 文档

README

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

A comprehensive page management system for Filament v4 with advanced features including template-based content management, regions, multilingual support, SEO optimization, and hierarchical page structures.

Features

  • Page Management: Create and manage static pages with hierarchical structure
  • Template System: Flexible template-based content architecture
  • Region Management: Reusable content blocks across pages
  • Multilingual Support: Full translation support with locale management
  • SEO Optimization: Built-in SEO fields and meta tag management
  • Drag & Drop Sorting: Reorderable pages with sort order
  • Draft/Publish System: Control page visibility with publish states
  • Page Duplication: Quick page copying with automatic slug generation
  • Cache Management: Optimized performance with intelligent caching
  • PHP 8.3 Features: Leveraging modern PHP capabilities
  • PHPStan Level 8: Full static analysis compliance for type safety
  • 100% Test Coverage: Comprehensive test suite with Pest PHP

Requirements

  • PHP 8.3 or higher
  • Laravel 11.0 or higher
  • Filament 4.0 or higher

Installation

You can install the package via composer:

composer require iamgerwin/filament-page-manager

Register the plugin in your Panel provider (e.g., app/Providers/Filament/AdminPanelProvider.php):

use IamGerwin\FilamentPageManager\FilamentPageManagerPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        // ... other configuration
        ->plugins([
            FilamentPageManagerPlugin::make(),
        ]);
}

You can publish and run the migrations with:

php artisan vendor:publish --tag="filament-page-manager-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="filament-page-manager-config"

Optionally, you can publish the views using

php artisan vendor:publish --tag="filament-page-manager-views"

Configuration

The configuration file config/filament-page-manager.php allows you to customize:

  • Database table names
  • Model and resource classes
  • Template registration
  • Locale settings
  • SEO configuration
  • Navigation settings
  • Feature toggles
  • Cache settings

Basic Configuration

return [
    'tables' => [
        'pages' => 'fpm_pages',
        'regions' => 'fpm_regions',
    ],

    'locales' => [
        'en' => 'English',
        'es' => 'Spanish',
        'fr' => 'French',
    ],

    'default_locale' => 'en',

    'seo' => [
        'enabled' => true,
        'fields' => [
            'title' => ['label' => 'SEO Title', 'maxLength' => 60],
            'description' => ['label' => 'SEO Description', 'maxLength' => 160],
        ],
    ],
];

Usage

Creating Page Templates

Create a new page template:

php artisan filament-page-manager:make-template HomePage --type=page

This generates a template class in app/PageTemplates/HomePageTemplate.php:

<?php

namespace App\PageTemplates;

use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\TextInput;
use IamGerwin\FilamentPageManager\Templates\AbstractPageTemplate;

class HomePageTemplate extends AbstractPageTemplate
{
    public function name(): string
    {
        return 'Home Page';
    }

    public function fields(): array
    {
        return [
            Section::make('Hero Section')
                ->schema([
                    TextInput::make('hero_title')
                        ->label('Hero Title')
                        ->required()
                        ->maxLength(255),

                    RichEditor::make('hero_content')
                        ->label('Hero Content')
                        ->required(),
                ]),
        ];
    }

    public function pathSuffix(): ?string
    {
        return null; // or '.html' for specific URL patterns
    }
}

Creating Region Templates

Create a region template:

php artisan filament-page-manager:make-template Footer --type=region
<?php

namespace App\RegionTemplates;

use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\TextInput;
use IamGerwin\FilamentPageManager\Templates\AbstractRegionTemplate;

class FooterTemplate extends AbstractRegionTemplate
{
    public function name(): string
    {
        return 'Footer';
    }

    public function fields(): array
    {
        return [
            TextInput::make('copyright')
                ->label('Copyright Text')
                ->required(),

            Repeater::make('links')
                ->label('Footer Links')
                ->schema([
                    TextInput::make('title')->required(),
                    TextInput::make('url')->url()->required(),
                ])
                ->columns(2),
        ];
    }
}

Registering Templates

Register your templates in the configuration file:

'templates' => [
    App\PageTemplates\HomePageTemplate::class,
    App\PageTemplates\AboutPageTemplate::class,
    App\PageTemplates\ContactPageTemplate::class,
    App\RegionTemplates\HeaderTemplate::class,
    App\RegionTemplates\FooterTemplate::class,
],

Using in Your Application

Retrieving Pages

use IamGerwin\FilamentPageManager\Facades\FilamentPageManager;

// Get all published pages
$pages = FilamentPageManager::getPages();

// Get pages by template
$blogPages = FilamentPageManager::getPages([BlogPageTemplate::class]);

// Get page by slug
$page = FilamentPageManager::getPageBySlug('about-us', 'en');

// Get hierarchical page structure
$structure = FilamentPageManager::getPagesStructure();

// Get formatted page data for frontend
$pageData = FilamentPageManager::formatPage($page, 'en');

Using Helper Functions

// Get page by slug
$page = fpm_get_page_by_slug('about-us');

// Get pages structure
$structure = fpm_get_pages_structure();

// Get region by name
$footer = fpm_get_region('footer');

// Format data for frontend
$formatted = fpm_format_page($page);

Working with Regions

// Get all regions
$regions = FilamentPageManager::getRegions();

// Get region by name
$header = FilamentPageManager::getRegionByName('header');

// Format region data
$headerData = FilamentPageManager::formatRegion($header, 'en');

Blade Views Integration

@php
    $page = fpm_get_page_by_slug(request()->path());
    $header = fpm_get_region('header');
@endphp

<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
    <title>{{ $page->seo['title'] ?? $page->name }}</title>
    <meta name="description" content="{{ $page->seo['description'] ?? '' }}">
</head>
<body>
    @if($header)
        <header>
            {!! $header->data['content'] !!}
        </header>
    @endif

    <main>
        <h1>{{ $page->data['title'] }}</h1>
        {!! $page->data['content'] !!}
    </main>
</body>
</html>

Advanced Features

Multilingual Support

Configure multiple locales in your config:

'locales' => [
    'en' => 'English',
    'es' => 'Spanish',
    'fr' => 'French',
    'de' => 'German',
],

Access translated content:

$page->getTranslation('slug', 'es');
$page->setTranslation('data', 'fr', ['title' => 'Titre Français']);

Custom Models

Extend the base models for custom functionality:

namespace App\Models;

use IamGerwin\FilamentPageManager\Models\Page as BasePage;

class Page extends BasePage
{
    public function generateMetaTags(): string
    {
        // Custom meta tag generation
    }
}

Update configuration:

'models' => [
    'page' => App\Models\Page::class,
],

Cache Management

The package includes intelligent caching:

// Clear all caches
FilamentPageManager::clearCache();

// Or using helper
fpm_clear_cache();

Configure cache settings:

'cache' => [
    'enabled' => true,
    'ttl' => 3600, // 1 hour
    'tags' => ['filament-page-manager'],
],

Testing

composer test

Quality Assurance

This package maintains high code quality standards:

  • PHPStan Level 8: Full static analysis for type safety
  • PSR-12: Coding standards compliance
  • Pest PHP: Modern testing framework
  • GitHub Actions: Automated CI/CD pipeline

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

If you discover any security-related issues, please email iamgerwin@live.com instead of using the issue tracker.

Credits

License

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

iamgerwin/filament-page-manager 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-23