tonning/bladebook
Composer 安装命令:
composer require tonning/bladebook
包简介
Storybook for Blade components
README 文档
README
Not ready for production just yet.
Storybook for Blade components
To come.
Installation
You can install the package via composer:
composer require tonning/bladebook
You need to publish the assets to your applications public/vendor directory:
php artisan vendor:publish --provider="Tonning\Bladebook\BladebookServiceProvider" --tag="bladebook:assets"
You are free to also publish the config file:
php artisan vendor:publish --provider="Tonning\Bladebook\BladebookServiceProvider" --tag="config"
Discover Bladebook components
php artisan bladebook:discover
Creating Bladebook components
After you've created your normal Blade components you need to write some simple wrappers around them in order for them to be visible in the Bladebook UI. Let's say you've already created a simple Blade card component.
app/Views/Components/Layouts/Card.php
<?php namespace App\Views\Components\Layouts; use Illuminate\View\Component; class Card extends Component { public ?string $title = null; public function __construct(string $title = null) { $this->title = $title; } public function render() { return view('components.layouts.card'); } }
resources/views/components.layouts.card.blade.php
<div {{ $attributes->merge(['class' => 'bg-white overflow-hidden shadow rounded-md']) }}> @if($title) <div class="bg-white px-4 py-5 border-b border-gray-200 sm:px-6"> <h3 class="text-lg leading-6 font-medium text-gray-900"> {{ $title }} </h3> </div> @endif <div class="px-4 py-5 sm:p-6 space-y-6"> {{ $slot }} </div> @isset($footer) <div class="px-4 py-3 bg-gray-50 text-right sm:px-6"> {{ $footer }} </div> @endisset </div>
Register books
To register a book, you need to provide three (3) pieces of information;
- The name of the book
- The Blade component namespace that your components use
- And the namespace where you Bladebook components live (usually
App\Http\Bladebook)
This is usually done register method in your service provider i.e. AppServiceProvider:
$this->callAfterResolving(BladebookComponentsFinder::class, function (BladebookComponentsFinder $bladebook) { $bladebook->registerBook(name: 'fabrick', bladeComponentNamespace: 'fab', namespace: 'App\Http\Bladebook'); });
Styles and Scripts
Normally you application has it's own set of styles and scripts that are needed to render your components correctly. You can register the paths to these so Bladebook is able to display your components as intended.
$this->callAfterResolving(BladebookComponentsFinder::class, function (BladebookComponentsFinder $bladebook) { $bladebook->registerBook(name: 'fabrick', bladeComponentNamespace: 'fab', namespace: 'App\Http\Bladebook') ->registerStylePaths('/css/app.css') ->registerScriptPaths('/js/app.js');; });
Auth
You can lockdown access to Bladebook's UI by defining a gate in one of your service provider's boot method. AuthServiceProvider is a good place to put it.
Bladebook's UI is always available in your local environment.
Gate::define('viewBladebook', function ($user) { return true; });
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.
tonning/bladebook 适用场景与选型建议
tonning/bladebook 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 8.67k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2021 年 06 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「components」 「laravel」 「blade」 「tonning」 「storybook」 「bladebook」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tonning/bladebook 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tonning/bladebook 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tonning/bladebook 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Web Font Loader gives you added control when using linked fonts via @font-face.
Ariadne Component Library: xml writer and parser Component
Ariadne Component Library: Cache Component
Ariadne Component Library: hierarchical configuration management Component
Ariadne Component Library: user and group rights management Component
Ariadne Component Library: W3C style events Component
统计信息
- 总下载量: 8.67k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-09