featherwebs/filament-pages
Composer 安装命令:
composer require featherwebs/filament-pages
包简介
Highly opinionated Pages for filament. Forked from beier/filament-pages
README 文档
README
beier/filament-pages
A starting point to create a Page Resource and front routing with filament. It is the result of packaging our Page CMS functionality.
This package does not register any routes, as page routing always depends on your project. This is meant to be providing you a quickstart in creating a dynamic page module.
Demo
Screenshots
Installation
You can install the package via composer:
composer require beier/filament-pages
You can run the installation command with:
php artisan filament-pages:install
This is the contents of the published config file:
<?php use Beier\FilamentPages\Filament\FilamentPageTemplates\DefaultTemplate; use Beier\FilamentPages\Filament\Resources\FilamentPageResource; use Beier\FilamentPages\Models\FilamentPage; use Beier\FilamentPages\Renderer\SimplePageRenderer; return [ 'filament' => [ /* |-------------------------------------------------------------------------- | Filament: Custom Filament Resource |-------------------------------------------------------------------------- | | Use your own extension of the FilamentPageResource | below to fully customize every aspect of it. | */ 'resource' => FilamentPageResource::class, /* |-------------------------------------------------------------------------- | Filament: Custom Filament Model |-------------------------------------------------------------------------- | | Use your own extension of the FilamentPage Model | below to fully customize every aspect of it. | */ 'model' => FilamentPage::class, /* |-------------------------------------------------------------------------- | Filament: Title Attribute |-------------------------------------------------------------------------- | | Point to another field or Attribute to change the | computed record title provided in filament. | */ 'recordTitleAttribute' => 'title', /* |-------------------------------------------------------------------------- | Filament: Label |-------------------------------------------------------------------------- | | If you don't need to support multiple languages you can | globally change the model label below. If you do, | you should rather change the translation files. | */ 'modelLabel' => 'Page', /* |-------------------------------------------------------------------------- | Filament: Plural Label |-------------------------------------------------------------------------- | | If you don't need to support multiple languages you can | globally change the plural label below. If you do, | you should rather change the translation files. | */ 'pluralLabel' => 'Pages', 'navigation' => [ /* |-------------------------------------------------------------------------- | Filament: Navigation Icon |-------------------------------------------------------------------------- | | If you don't need to support multiple languages you can | globally change the navigation icon below. If you do, | you should rather change the translation files. | */ 'icon' => 'heroicon-o-document', /* |-------------------------------------------------------------------------- | Filament: Navigation Group |-------------------------------------------------------------------------- | | If you don't need to support multiple languages you can | globally change the navigation group below. If you do, | you should rather change the translation files. | */ 'group' => 'content', /* |-------------------------------------------------------------------------- | Filament: Navigation Group |-------------------------------------------------------------------------- | | If you don't need to support multiple languages you can | globally change the navigation sort below. If you do, | you should rather change the translation files. | */ 'sort' => null, ] ], /* |-------------------------------------------------------------------------- | Templates |-------------------------------------------------------------------------- | | Add your own Templates implementing FilamentPageTemplate::class | below. They will appear in the Template selection, | and persisted to the data column. | */ 'templates' => [ DefaultTemplate::class, ], /* |-------------------------------------------------------------------------- | Renderer |-------------------------------------------------------------------------- | | If you want to use the Rendering functionality, you can create your | own Renderer here. Take the available Renderers for reference. | See FilamentPageController for recommended usage. | | Available Renderers: | - SimplePageRenderer: | Renders everything to the defined layout below. | - AtomicDesignPageRenderer: | More opinionated Renderer to be used with Atomic Design. | | To use the renderer, Add a Route for the exemplary FilamentPageController: | | Route::get('/{filamentPage}', [FilamentPageController::class, 'show']); | | To route the homepage, you could add a data.is_homepage | field and query it in a controller. | */ 'renderer' => SimplePageRenderer::class, /* |-------------------------------------------------------------------------- | Simple Page Renderer: Default Layout |-------------------------------------------------------------------------- | | Only applicable to the SimplePageRenderer. | */ 'default_layout' => 'layouts.app', ];
Usage
Within Filament
After running the Install Command, you will find a new Page Resource in your Filament Admin.
Templates
This package uses the concept of Template-based forms by Dennis Koch (pxlrbt). You can read more about the general idea in his Filament Trick.
You will find a basic page template. By creating and selecting your own templates, you are able to fully customize your pages.
To create your own Templates, implement the Beier\FilamentPages\Contracts\FilamentPageTemplate:
<?php namespace App\Filament\FilamentPageTemplates; use Beier\FilamentPages\Contracts\FilamentPageTemplate; use Filament\Forms\Components\Card; use Filament\Forms\Components\RichEditor; class MyTemplate implements FilamentPageTemplate { public static function title(): string { return 'My Template'; } public static function schema(): array { return [ Card::make() ->schema([ RichEditor::make('content') ]), ]; } }
Finally, register your template in config/filament-pages.php:
<?php return [ 'templates' => [ // \Beier\FilamentPages\Filament\FilamentPageTemplates\DefaultTemplate::class, \App\Filament\FilamentPageTemplates\MyTemplate::class, ], ];
Your template will appear in the Template Selection and render your schema accordingly.
Customizing the Page Resource
The recommended way of extending the Page Resource is overriding
FilamentPageResource::insertBeforePrimaryColumnSchemaFilamentPageResource::insertAfterPrimaryColumnSchemaFilamentPageResource::insertBeforeSecondaryColumnSchemaFilamentPageResource::insertAfterSecondaryColumnSchema
in your own PageResource class, extending Beier\FilamentPages\Filament\Resources\FilamentPageResource.
You will find most common configuration options in the config file.
<?php namespace App\Filament\Resources; use Beier\FilamentPages\Filament\Resources\FilamentPageResource; use Filament\Resources\Form; use Filament\Resources\Table; use Filament\Forms\Components\Toggle; use Filament\Forms\Components\TextInput; class PageResource extends FilamentPageResource { /** * Recommended: Insert Fields at the beginning of the primary column. */ public static function insertBeforePrimaryColumnSchema(): array { return [ Toggle::make('is_homepage'), ]; } /** * Recommended: Insert Fields at the end of the primary column. */ public static function insertAfterPrimaryColumnSchema(): array { return [ TextInput::make('author'), ]; } /** * Recommended: Insert Fields at the beginning of the secondary column. (sidebar) */ public static function insertBeforeSecondaryColumnSchema(): array { return [ Toggle::make('is_homepage'), ]; } /** * Recommended: Insert Fields at the end of the secondary column. (sidebar) */ public static function insertAfterSecondaryColumnSchema(): array { return [ SEO::make(), ]; } /** * Not Recommended: Override the whole form */ /** public static function form(Form $form): Form { return $form ->schema([ // ]); } */ /** * Not Recommended: Override the whole table */ /** public static function table(Table $table): Table { return $table ->columns([ // ]); } */ }
Then, register your class within config/filament-pages.php
<?php use App\Filament\Resources\PageResource; return [ 'filament' => [ 'resource' => PageResource::class, ], ]
Examples
Usage with laravel-filament-seo
-
Create
app/Models/FilamentPage.php<?php namespace App\Models; use Beier\FilamentPages\Models\FilamentPage as BeierFilamentPage; use RalphJSmit\Laravel\SEO\Support\HasSEO; use RalphJSmit\Laravel\SEO\Support\SEOData; class FilamentPage extends BeierFilamentPage { use HasSEO; public function getDynamicSEOData(): SEOData { return new SEOData( title: $this->title, ); } }
-
Create
app/Filament/Resources/PageResource.php<?php namespace App\Filament\Resources; use RalphJSmit\Filament\SEO\SEO; use Beier\FilamentPages\Filament\Resources\FilamentPageResource; class PageResource extends FilamentPageResource { public static function insertAfterSecondaryColumnSchema(): array { return [ SEO::make(), ]; } }
-
Define Model and Resource in
config/filament-pages.phpreturn [ 'filament' => [ 'resource' => \App\Filament\Resources\PageResource::class, 'model' => \App\Models\FilamentPage::class, ], ];
-
If necessary, clear application caches for the Service Locator to load your resource:
$ php artisan cache:clear
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
featherwebs/filament-pages 适用场景与选型建议
featherwebs/filament-pages 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 46 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 06 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「filament」 「filament-pages」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 featherwebs/filament-pages 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 featherwebs/filament-pages 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 featherwebs/filament-pages 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Highly opinionated Pages for filament
Alfabank REST API integration
A Filament plugin for managing hierarchical, block-based content pages with a drag-and-drop page tree, SEO integration, and live preview
Database-driven onboarding for Filament: progress checklists and guided spotlight tours, translatable to any locale.
Functionality for handling basic Page Resources within Filament.
Laravel package for Accurate Online API integration.
统计信息
- 总下载量: 46
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-06-26


