mrshanebarron/comments
最新稳定版本:v1.0.1
Composer 安装命令:
composer require mrshanebarron/comments
包简介
Comments/discussion component for Laravel - supports Livewire and Vue
README 文档
README
A threaded comments component for Laravel applications. Display and manage user comments with replies, avatars, and timestamps. Works with Livewire and Vue 3.
Installation
composer require mrshanebarron/comments
Livewire Usage
Basic Usage
<livewire:sb-comments :comments="$comments" :current-user="auth()->user()->name" />
With Replies
<livewire:sb-comments :comments="$comments" :current-user="auth()->user()->name" :current-user-avatar="auth()->user()->avatar_url" :allow-replies="true" />
Livewire Props
| Prop | Type | Default | Description |
|---|---|---|---|
comments |
array | [] |
Array of comment objects |
current-user |
string | null |
Current user's name |
current-user-avatar |
string | null |
Current user's avatar URL |
allow-replies |
boolean | true |
Enable reply functionality |
Vue 3 Usage
Setup
import { SbComments } from './vendor/sb-comments'; app.component('SbComments', SbComments);
Basic Usage
<template> <SbComments :comments="comments" :current-user="currentUser.name" :current-user-avatar="currentUser.avatar" @add-comment="handleAddComment" @add-reply="handleAddReply" /> </template> <script setup> import { ref } from 'vue'; const currentUser = { name: 'John Doe', avatar: '/avatars/john.jpg' }; const comments = ref([ { id: '1', author: 'Jane Smith', avatar: '/avatars/jane.jpg', content: 'Great article!', timestamp: new Date().toISOString(), replies: [] } ]); const handleAddComment = (comment) => { comments.value.push(comment); }; const handleAddReply = ({ parentIndex, comment }) => { comments.value[parentIndex].replies.push(comment); }; </script>
Vue Props
| Prop | Type | Default | Description |
|---|---|---|---|
comments |
Array | [] |
Array of comment objects |
currentUser |
String | null |
Current user's display name |
currentUserAvatar |
String | null |
Current user's avatar URL |
allowReplies |
Boolean | true |
Enable threaded replies |
Events
| Event | Payload | Description |
|---|---|---|
add-comment |
comment |
New comment submitted |
add-reply |
{ parentIndex, comment } |
Reply submitted |
Comment Object
{ id: 'unique-id', author: 'User Name', avatar: '/path/to/avatar.jpg', content: 'Comment text...', timestamp: '2024-01-15T10:30:00Z', replies: [/* nested comments */] }
Features
- Threaded Replies: Nested comment threads
- Avatars: User avatars with fallback initials
- Timestamps: Relative time display (just now, 5m ago, etc.)
- Reply Toggle: Click to reply to specific comments
- Cancel Reply: Easy cancel for reply mode
Styling
Uses Tailwind CSS:
- Rounded avatars
- Indented reply threads
- Border separators
- Hover states
Requirements
- PHP 8.1+
- Laravel 10, 11, or 12
- Tailwind CSS 3.x
License
MIT License
mrshanebarron/comments 适用场景与选型建议
mrshanebarron/comments 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mrshanebarron/comments 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mrshanebarron/comments 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-16