haringsrob/filament-page-builder 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

haringsrob/filament-page-builder

Composer 安装命令:

composer require haringsrob/filament-page-builder

包简介

A visual page builder for Filament

README 文档

README

Latest Version on Packagist run-tests Fix PHP code style issuesTotal Downloads

With this package you have a new Filament field (like Builder) but with a visual ui and dynamic types.

Please not that this is a pre-production package, there are many things potentially still bugged and it may not work together with some other packages (like translations).

Methods and flow may still change before a first release, so if you use it, keep in mind that a composer update may break it.

If you encounter issues, please provide a pull request.

To see a demo:

Simple demo

Installation

You can install the package via composer:

composer require sevendays/filament-page-builder

You can publish and run the migrations with:

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

You can publish the config file with (currently no config):

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

Optionally, you can publish the views using

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

This is the contents of the published config file:

return [
];

Usage

Filament page builder is a custom Filament field that adds functionality on top of the Builder field.

13-11-2023 Preview is now opt-in via config.

  • Preview can interfere with forms configured within blocks
  • Preview sets all block fields to reactive, for the 'live' preview part

If you are ok with that, you can enable the preview via:

return [
    'enablePreview' => true,
];

To use this, create a Model and Resource as per the Filament documentation then do the following:

1. Generate a block

You can use the command below to generate a block:

php artisan make:page-builder-block DemoBlock

This will create 2 files:

app/Filament/Blocks/DemoBlock.php: This is where you define the form fields and render view. resources/views/filament/blocks/demo-block.blade.php: This is how your block is supposed to be rendered.

The default generator provides just a 'title' field.

NOTE: All fields are translatable by default. However you can have shared fields by adding the following method with the field id's:

public static function getSharedFields(): array
{
    return ['show'];
}

public function form(): array
{
    return [
        TextInput::make('title'),
        Toggle::make('show')
    ];
}

2. Add the contract and trait to your model

In order to save blocks, you need to add the Blockable interface and HasBlocks trait to your model.

<?php

namespace App\Models;

use Sevendays\FilamentPageBuilder\Models\Contracts\Blockable;
use Sevendays\FilamentPageBuilder\Models\Traits\HasBlocks;
use Illuminate\Database\Eloquent\Model;

class Page extends Model implements Blockable
{
    use HasBlocks;

    protected $fillable = [
        'title'
    ];
}

3. Add the field to your resource form

In your resource form we can now add the field:

<?php
use Sevendays\FilamentPageBuilder\Forms\Components\BlockEditor;
use App\Filament\Blocks\DemoBlock;

public static function form(Form $form): Form
{
    return $form
        ->schema([
            BlockEditor::make('blocks')
                ->blocks([ // You can add more blocks here.
                    DemoBlock::class,
                ])
                ->renderInView('blocks.preview'), // Optional: To render the preview in a different view.
        ]);
}

If all goes well, you should now have the block builder on your page. Do not forget to run migrations.

4. Rendering on the front-end

There are not many tools for this yet but basic rendering works like this:

@foreach($page->blocks as $block)
    {!! \Sevendays\FilamentPageBuilder\Facades\BlockRenderer::renderBlock($block) !!}
@endforeach

$page is your model that has blocks.

Testing

Not done yet.

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.

haringsrob/filament-page-builder 适用场景与选型建议

haringsrob/filament-page-builder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 342 次下载、GitHub Stars 达 54, 最近一次更新时间为 2023 年 04 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 54
  • Watchers: 5
  • Forks: 11
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-29