wsmallnews/comment
Composer 安装命令:
composer require wsmallnews/comment
包简介
Wsmallnews system comment modules
关键字:
README 文档
README
A versatile commenting system built on Laravel + Filament. It supports multi-tenancy, multi-scope isolation, nested replies, likes, rich text content, out-of-the-box front-end Livewire components, and Filament admin panel.
Overview
- Polymorphic Comments:Any Eloquent model can be a comment subject (Commentable)
- Polymorphic Commenters:Support any model as a commenter (Commenter)
- Nested Replies:Support two-level replies, automatically associate with the replied-to (BeReplyer)
- Scope Isolation:Through scope_type + scope_id, multi-scope data isolation is achieved
- Multi-Tenantancy Support:Automatically associate with team team_id
- Content Types:Support plain text, rich text (Richtext), and Markdown content types
- Comment Status:Support normal, pending, and hidden comment statuses
- Like Function:Based on Wsmallnews/preference extension
- Filament Admin Panel:Full comment management page
- Front-end Livewire Components:开箱即用的 Livewire comment list and comment input components
- Highly Configurable:Support custom models, default status, content types, etc
- Register the CommentPlugin:Based on bezhansalleh/filament-plugin-essentials extension
Installation
You can install the package via composer:
composer require wsmallnews/comment:^1.0
Installing this package will publish the configuration files and migration files of both the third-party dependency package and the current package:
php artisan sn-comment:install
You can publish only the config file individually:
php artisan vendor:publish --tag="sn-comment-config"
Publish and run only the migrations individually:
php artisan vendor:publish --tag="sn-comment-migrations"
php artisan migrate
Multi language support, you can publish the language files using
php artisan vendor:publish --tag="sn-comment-translations"
Optionally, you can publish the views using:
php artisan vendor:publish --tag="sn-comment-views"
This is the contents of the published config file:
use Wsmallnews\Comment\Enums\CommentStatus; use Wsmallnews\Comment\Models; use Wsmallnews\Support\Enums\ContentType; return [ /** * Default scopeable */ 'scopeable' => [ 'scope_type' => 'sn-comment', 'scope_id' => 0, ], /** * Default comment contentType */ 'default_content_type' => ContentType::Textarea, /** * Default comment status */ 'default_status' => CommentStatus::Normal, /** * Custom models */ 'models' => [ 'comment' => Models\Comment::class, 'comment_content' => Models\CommentContent::class, ], /** * File base directory (only used by filament default upload component (Forms\Components\FileUpload)) */ 'file_directory' => 'sn/comment/', ];
Quick Start
1. Add comment capability to your models
Give your models comment capability by adding the corresponding Traits:
use Illuminate\Database\Eloquent\Model; use Wsmallnews\Comment\Models\Concerns\Commentable; use Wsmallnews\Comment\Models\Concerns\Commenter; use Wsmallnews\Comment\Models\Concerns\BeReplyer; class Post extends Model { // As commentable (the object being commented on) use Commentable; } class User extends Model { // As commenter (the user commenting on the object) use Commenter; // As be replyer use BeReplyer; }
2. Use the Livewire component
Use the Livewire component in your Blade view:
<livewire:sn-comment-components-comments
scopeType="default"
:scopeId="0"
:commentable="$post"
:properties="[
'emptyLabel' => 'No comments',
'emptyTipLabel' => 'Add your first comment'
]"
:contentType="\Wsmallnews\Support\Enums\ContentType::Textarea"
page-name="cp"
/>
3. Custom theme
You should use a filament custom theme
You should add the following code to your custom theme file. If you custom theme file is /resources/css/filament/admin/theme.css
@import '../../../../vendor/wsmallnews/support/resources/css/index.css'; @import '../../../../vendor/wsmallnews/comment/resources/css/index.css';
Filament Integration
Register the CommentPlugin
Register the CommentPlugin in your Panel configuration:
use Wsmallnews\Comment\CommentPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ CommentPlugin::make() ->forResource(CommentPage::class) ->navigationLabel('Comment manage') ->navigationGroup('Website manage') ->navigationIcon(Heroicon::OutlinedChatBubbleLeft) ->activeNavigationIcon(Heroicon::ChatBubbleLeft) ->navigationSort(10) ->modelLabel('Comment') ->pluralModelLabel('Comments') ->customProperties([ 'contentType' => ContentType::Textarea, 'commentStatus' => CommentStatus::Normal, 'emptyLabel' => 'No comments', 'emptyTipLabel' => 'Add your first comment', ]), ]); }
Available Properties
You can use the customProperties() method to customize the following properties:
| Property | Description | Default |
|---|---|---|
contentType |
Content type enum | ContentType::Textarea |
commentStatus |
Comment status enum | CommentStatus::Normal |
emptyLabel |
Empty comment label | Language package default |
emptyTipLabel |
Empty comment tip label | Language package default |
Backend Page
After registration, you can view all comments in the Filament backend navigation:
Custom comment page
To customize the comment page, you can extend Wsmallnews\Comment\Filament\Pages\Comment\Base class in your own namespace:
<?php namespace App\Filament\Pages\Comment; use Wsmallnews\Comment\Filament\Pages\Comment\Base; class CommentPage extends Base { }
Widget
To use the comment widget in your Filament page comment page:
use Wsmallnews\Comment\Filament\Pages\Comment\Widgets\Comment as CommentWidget; class ViewPost extends ViewRecord { protected function getFooterWidgets(): array { return [ CommentWidget::make([ 'scopeType' => 'default', 'scopeId' => 0, 'widgetType' => 'commentable', // commentable = Commentable | commenter = Commenter 'canAddComment' => true, ]), ]; } }
To use the comment widget in your Filament page comment page for a commenter:
use Wsmallnews\Comment\Filament\Pages\Comment\Widgets\Comment as CommentWidget; class ViewUser extends ViewRecord { protected function getFooterWidgets(): array { return [ CommentWidget::make([ 'scopeType' => 'default', 'scopeId' => 0, 'widgetType' => 'commenter', // commentable = Commentable | commenter = Commenter 'canAddComment' => true, ]), ]; } }
Widget Properties
| Property | Description | Default |
|---|---|---|
scopeType |
Scope type | default |
scopeId |
Scope ID | 0 |
widgetType |
Widget type commentable = Commentable ,commenter = Commenter | commentable |
canAddComment |
Whether to allow adding comments | false |
contained |
Whether to contain the widget | true |
commentStatus |
Comment status enum | CommentStatus::Normal |
contentType |
Content type enum | ContentType::Textarea |
properties |
Properties array | [] |
Livewire Component
Comment List Component
<livewire:sn-comment-components-comments
scopeType="default"
:scopeId="0"
:commentable="$post"
:properties="[
'emptyLabel' => 'No comments',
'emptyTipLabel' => 'Add your first comment'
]"
:contentType="\Wsmallnews\Support\Enums\ContentType::Textarea"
page-name="cp"
/>
| Property | Description | Default |
|---|---|---|
scopeType |
Scope type | default |
scopeId |
Scope ID | 0 |
canAddComment |
Whether to allow adding comments | false |
contained |
Whether to contain the widget | true |
pageType |
Page type scroll:Scroll,paginator:Paginator,manual:Manual | scroll |
pageName |
Page name | page |
perPage |
Per page comments count | 10 |
user |
user instance | null |
commentStatus |
Comment status enum | CommentStatus::Normal |
contentType |
Content type enum | ContentType::Textarea |
properties |
Properties array | [] |
The component will automatically handle:
- Comment pagination
- Nested reply expand/collapse
- Like count display
- Commenter avatar and nickname display
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
- smallnews
- bezhansalleh/filament-plugin-essentials
- filament/filament
- Wsmallnews/preference
- Wsmallnews/support
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
wsmallnews/comment 适用场景与选型建议
wsmallnews/comment 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 04 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「comment」 「laravel」 「Wsmallnews」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wsmallnews/comment 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wsmallnews/comment 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wsmallnews/comment 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A simple tool for checking that your PHP classes and methods use PHPDocs (PHP DocBlocks Checker fork).
Filament nestedset tree builder powered by kalnoy/nestedset with Filament v4 and v5 support
This Bundle provides threaded comment functionality for Symfony applications
This package provides your visitors the possibility to comment stuff and discuss together.
A simple tool for checking that your PHP classes and methods use docblocks.
Alfabank REST API integration
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 29
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-11