smileitworks/livewire-event-debugger 问题修复 & 功能扩展

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

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

smileitworks/livewire-event-debugger

最新稳定版本:v1.0.2

Composer 安装命令:

composer require smileitworks/livewire-event-debugger

包简介

Debug and log all Livewire events in development

README 文档

README

A powerful debugging tool for Livewire that automatically logs all events (both client-side and server-side) to help you debug your Livewire applications.

Features

  • 🔵 Logs all client-side events (Livewire.dispatch(), Livewire.dispatchTo())
  • 🟢 Logs all server-side events ($this->dispatch() in PHP)
  • 🎯 Environment-aware (only enabled in development)
  • 📊 Detailed or simple logging formats
  • ⚡ Zero performance impact in production

Installation

composer require smileitworks/livewire-event-debugger --dev

Configuration

Publish the config file (optional, but recommended):

php artisan vendor:publish --tag=livewire-event-debugger-config

Note: The JavaScript assets are automatically served from the vendor directory. If you prefer to serve them from your public directory (e.g., for CDN distribution), you can publish them:

php artisan vendor:publish --tag=livewire-event-debugger-assets

Edit config/livewire-event-debugger.php:

return [
    'enabled_environments' => ['local', 'testing'],
    'console_logging' => true,
    'log_format' => 'detailed', // or 'simple'
];

Usage

Option 1: Using Blade Component (Recommended)

Add to your layout file (e.g., resources/views/partials/head.blade.php):

<x-livewire-event-debugger-script />

Option 2: Manual Integration

Add to your layout file:

@php
    $config = config('livewire-event-debugger', []);
    $enabledEnvironments = $config['enabled_environments'] ?? ['local', 'testing'];
    $isEnabled = in_array(app()->environment(), $enabledEnvironments);
@endphp

@if($isEnabled)
    <meta name="livewire-event-debugger-enabled" content="true">
    <meta name="livewire-event-debugger-console" content="{{ $config['console_logging'] ?? true ? 'true' : 'false' }}">
    <meta name="livewire-event-debugger-format" content="{{ $config['log_format'] ?? 'detailed' }}">
    <script src="{{ asset('vendor/livewire-event-debugger/livewire-event-debugger.js') }}"></script>
@endif

Option 3: Using Vite

If you prefer to bundle it with Vite, copy the JS file to your resources and import it:

// In resources/js/app.js
import "./livewire-event-debugger";

How It Works

The package hooks into Livewire's JavaScript API to intercept:

  1. Client-side dispatches: Overrides Livewire.dispatch() and Livewire.dispatchTo()
  2. Server-side dispatches: Uses Livewire's commit hook to catch events from PHP $this->dispatch() calls

All events are logged to the browser console with:

  • Event name
  • Parameters
  • Component name (for server-side events)
  • Timestamp (in detailed mode)

Testing

Run the test suite:

composer test

Or with Pest directly:

vendor/bin/pest

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-21