smitmartijn/laravel-lookbook 问题修复 & 功能扩展

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

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

smitmartijn/laravel-lookbook

Composer 安装命令:

composer require smitmartijn/laravel-lookbook

包简介

Laravel Lookbook is a component development environment for Laravel that helps you build, document, and organize your Blade components in isolation.

README 文档

README

Laravel Lookbook is a component development environment for Laravel that helps you build, document, and organize your Blade components in isolation. Preview different component states, document usage examples, switch between light and dark modes to verify your components - all while working in your Laravel application. Inspired by the Ruby on Rails Lookbook gem, this package brings the same powerful component development workflow to the Laravel ecosystem.

Dark Mode

Lookbook with notification components in dark mode

Features

  • Component Previews: Render and display Blade components with their output.
  • Multiple Component Versions: Show different versions/states of the same component. (i.e., primary button, secondary button, etc.)
  • Source Code Display: View the Blade source code used to render the components.
  • Collapsible Folders: Organize components in collapsible category folders
  • Light/Dark Mode: Switch between light and dark themes for better visibility.
  • Component Generator: Artisan command to scaffold new component previews
  • Markdown Documentation: Add markdown-formatted notes to your components

Installation

  1. Install the package via Composer:
composer require --dev smitmartijn/laravel-lookbook
  1. Publish the configuration file and views:
php artisan vendor:publish --provider="LaravelLookbook\LookbookServiceProvider"
  1. Update the configuration file located at config/lookbook.php to optionally customize the route and other settings.

  2. Visit /lookbook to check out the interface!

  3. Optionally, add "./app/Lookbook/**/*.php", to the content array in tailwind.css.js, if you are going to be using classes in the component preview files.

Usage

  • Access the Lookbook interface at the configured route (default: /lookbook).
  • Organize your Blade component previews in the app/Lookbook directory.
  • Create component preview files to define how each component is displayed in the previews.

Creating component previews

  1. Create a component preview
# php artisan make:lookbook-component Button
Lookbook component created successfully in app/Lookbook/Button.php
  1. Edit the created component preview model (app/Lookbook/Button.php in example) to include the code for your Blade component. For example:
<?php

namespace App\Lookbook;

use LaravelLookbook\Support\ComponentPreview;
use Illuminate\Support\Facades\Blade;

class Button extends ComponentPreview
{
   /**
    * @name Primary button
    * @notes This is the button style you should use for most things.
    */
   public function primary()
   {
      return (string) Blade::render(<<<'HTML'
<x-button type="submit">
   Button Text
</x-button>
HTML);
   }

  /**
   * @name Success button
   * @notes
   * Use this button style when a form is filled out successfully, or we want to encourage users to click this.
   *
   * This style uses a `#008000` green color
   */
   public function success()
   {
      return (string) Blade::render(<<<'HTML'
<x-button type="submit" color="success">
   Link Text
</x-button>
HTML);
   }
}

Notes:

  • You can have as many functions inside the component preview files as you want.
  • The phpdoc block is optional. Without a @name the function name will be used as the component preview name.
  • The component name will be derived from the class name, but you can override it by adding a function to the class:
class Button extends ComponentPreview
{
   static public function getName()
   {
      return 'Button Component';
   }
   ...
}

Contributing

This package is in early stages, and contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.

Testing

Run the tests with:

composer test

License

This package is licensed under the LGPL-3.0 License. See the LICENSE file for more information.

smitmartijn/laravel-lookbook 适用场景与选型建议

smitmartijn/laravel-lookbook 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.67k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 03 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 smitmartijn/laravel-lookbook 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 2.67k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0-or-later
  • 更新时间: 2025-03-16