pboivin/laravel-blade-bind-attributes
最新稳定版本:v0.2.0
Composer 安装命令:
composer require pboivin/laravel-blade-bind-attributes
包简介
Attribute unpacking for Laravel Blade component tags
README 文档
README
⚠ EXPERIMENTAL ⚠
This package adds support for @bind attributes in Blade component tags. The new attribute allows you to extract all keys from a given array as component props:
@php $header = [ 'title' => 'Lorem ipsum', 'secondaryTitle' => 'Dolor sit amet', ]; @endphp <x-header @bind="$header" class="my-header" />
This is equivalent to:
<x-header :title="$header['title']" :secondary-title="$header['secondaryTitle']" class="my-header" />
Requirements
- PHP >= 8.1
- Laravel >= 9.x
Installation
composer require pboivin/laravel-blade-bind-attributes
php artisan view:clear
Caveats
With class-based components, make sure to include a @props() directive in your template, even when you are defining the props on the component class:
app/View/Components/Header.php :
class Header extends Component { public function __construct( public $title = 'Hello', public $secondaryTitle = 'World' ){} public function render() { return view('components.header'); } }
resources/views/components/header.blade.php :
@props([ 'title', 'secondaryTitle', ]) <div {{ $attributes }}> <h1>{{ $title }}</h1> <h2>{{ $secondaryTitle }}</h2> {{-- ... --}} </div>
Development
Test suite (phpunit)
composer run test
Code formatting (pint)
composer run format
License
This is open-sourced software licensed under the MIT license.
pboivin/laravel-blade-bind-attributes 适用场景与选型建议
pboivin/laravel-blade-bind-attributes 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 10 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「package」 「php」 「laravel」 「blade」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pboivin/laravel-blade-bind-attributes 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pboivin/laravel-blade-bind-attributes 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pboivin/laravel-blade-bind-attributes 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple ASCII output of array data
Alfabank REST API integration
Package for view storage in laravel
User Approval Laravel Package
PHPUnit Pretty Result Printer
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-31