iamgerwin / filament-page-manager
A comprehensive page management system for Filament v4 with templates, regions, SEO, and multilingual support
Fund package maintenance!
:vendor_name
Requires
- php: ^8.3
- filament/actions: ^4.0
- filament/filament: ^4.0
- filament/forms: ^4.0
- filament/infolists: ^4.0
- filament/notifications: ^4.0
- filament/tables: ^4.0
- filament/widgets: ^4.0
- illuminate/contracts: ^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- spatie/laravel-ray: ^1.35
README
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.