chat-agency/laravel-backend-component

使用 PHP 类使用 Laravel 组件

v0.3.1 2024-09-30 23:18 UTC

This package is auto-updated.

Last update: 2024-09-30 23:23:09 UTC


README

Backend Components 是一个包,它通过使用 PHP 类简化了 Laravel 组件的创建。

文档

安装

composer require chat-agency/laravel-backend-component

基本使用

使用 MainBackendComponent 类来构建你的组件。将组件名称作为第一个参数传递

use ChatAgency\BackendComponents\MainBackendComponent;

$button = new MainBackendComponent("inline.button");

或者,还有一个构建器和枚举,使创建实例更加容易

use ChatAgency\BackendComponents\Enums\ComponentEnum;
use ChatAgency\BackendComponents\MainBackendComponent;

$button = ComponentBuilder::make(ComponentEnum::BUTTON);

由于主组件类实现了 Laravel Htmlable 接口,因此你可以使用简单的 Blade 语法输出组件,无需使用未转义的语法

{{ $button }}