承接 iamgerwin/filament-page-manager 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

iamgerwin/filament-page-manager

最新稳定版本:v1.0.3

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.

统计信息

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

GitHub 信息

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

其他信息

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