z3d0x/filament-fabricator
Block-based page builder skeleton for Filament apps. Fabricator handles the PageResource and frontend routing so you can focus on layouts and reusable page blocks. Install via composer, run the installer, register the plugin in your panel, and publish assets.
Installation (Laravel 10+ / Laravel 11+ / Laravel 13+ compatible):
composer require z3d0x/filament-fabricator
php artisan filament-fabricator:install
Register the plugin in your Panel provider:
public function panel(Panel $panel): Panel {
return $panel->plugins([
FilamentFabricatorPlugin::make(),
]);
}
Publish assets:
php artisan filament:assets
First Use Case (Unchanged): Create a Layout and Page Block to build a page:
php artisan filament-fabricator:layout DefaultLayout
php artisan filament-fabricator:block HeroSection
DefaultLayout class and its Blade file (resources/views/layouts/default.blade.php).HeroSection in HeroSection::defineBlock().Access the Page Builder: Navigate to the Filament admin panel to create/edit pages using the block-based editor.
Layouts as Templates (Unchanged):
DefaultLayout with shared components like navigation or ads.// DefaultLayout.php
class DefaultLayout extends Layout {
protected static ?string $name = 'default';
}
resources/views/layouts/default.blade.php) to include static or dynamic content.Blocks as Modular Components (Unchanged):
Block field:// HeroSection.php
public static function defineBlock(Block $block): Block {
return $block->schema([
TextInput::make('title')->required(),
RichEditor::make('content'),
]);
}
@aware(['page']) in the Blade view to access the page model.Page Builder Configuration (Unchanged):
PageBuilder field globally or per-resource:PageBuilder::configureUsing(function (PageBuilder $builder) {
$builder->blockPickerStyle(BlockPickerStyle::Modal);
$builder->collapsible();
});
Dynamic Data Handling (Unchanged):
public static function mutateData(array $data): array {
return ['formattedTitle' => ucfirst($data['title'])];
}
public static function preloadRelatedData(Page $page, array &$blocks): void {
Helpers::preloadRelatedModels($blocks, 'items', 'ref', Post::class);
}
Integration with Filament Resources (Unchanged):
PageResource or create custom resources:class CustomPageResource extends PageResource {
public static function form(Form $form): Form {
return $form->schema([
PageBuilder::make('blocks')->blocks([
HeroSection::class,
TestimonialBlock::class,
]),
]);
}
}
Conditional Blocks (Unchanged): Restrict blocks to specific layouts using visibility rules:
Block::make('SpecialBlock')
->visible(fn ($get) => $get('../layout') === 'special-layout');
Shared Assets (Updated for Laravel 13): Register global scripts/styles via the facade (Laravel 13's Vite 5+ support):
FilamentFabricator::registerScripts([
app(Vite::class)('resources/js/app.js'),
]);
Custom Render Hooks (Unchanged): Extend the base layout with Filament render hooks:
@hook('filament-fabricator::head.start')
<meta name="theme-color" content="#312e81">
@endhook
Migration Issues (Updated):
filament-v5) and update dependencies:composer require filament/upgrade:"^5.0" -W --dev
./vendor/bin/filament-v5
Block Data Serialization (Unchanged):
mutateData() returns an array with valid Blade-compatible keys. Invalid keys may cause runtime errors.Layout Naming Conflicts (Unchanged):
base, default). Use unique prefixes like app_hero_section.Asset Loading (Updated for Laravel 13):
php artisan filament:assets after installing or updating the package will break the frontend.vite.config.js is properly configured for Filament assets.N+1 Queries (Unchanged):
preloadRelatedData() for blocks with relational data to optimize performance.Block Rendering Issues (Unchanged):
@aware(['page']) is included in the block’s Blade file.Configuration Overrides (Unchanged):
PageBuilder::configureUsing() in a service provider’s boot() method to ensure global settings are applied early.Custom Layouts (Unchanged):
filament-fabricator::page-blocks component is included to render blocks.Laravel 13 Debugging:
php artisan optimize:clear if encountering caching issues with new Laravel 13 features.Custom Block Picker (Unchanged):
Override the default block picker by extending BlockPicker and binding it to the PageBuilder:
PageBuilder::configureUsing(function (PageBuilder $builder) {
$builder->blockPicker(MyCustomBlockPicker::make());
});
Dynamic Layout Switching (Unchanged): Allow users to switch layouts via a dropdown in the page editor:
Select::make('layout')
->options(Layout::getAvailableLayouts())
->reactive()
->afterStateUpdated(fn ($state) => $this->evaluateFieldDependencies()),
Block Dependencies (Unchanged):
Use Filament’s reactive() and afterStateUpdated() to dynamically show/hide fields based on block selections:
TextInput::make('subtitle')
->visible(fn ($get) => $get('show_subtitle')),
Caching (Updated for Laravel 13): Cache layout/block data for high-traffic pages (Laravel 13's improved cache API):
public function getCachedData(): array {
return Cache::remember("page_{$this->id}_blocks", now()->addHours(1), function () {
return $this->blocks->toArray();
});
}
Cache::tags() for better cache organization if needed.Localization (Unchanged):
Support multi-language blocks by adding a locale field and translating content:
public static function mutateData(array $data): array {
return [
'title' => __($data['title']),
'content' => __($data['content']),
];
}
How can I help you explore Laravel packages today?