chat-agency / laravel-backend-component
使用 PHP 类使用 Laravel 组件
v0.3.1
2024-09-30 23:18 UTC
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- phpunit/phpunit: ^11.3
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 }}