
Commentify is a powerful Laravel Livewire package designed to provide an easy-to-integrate commenting system for any model in your Laravel application. Powered by Livewire, this package offers a seamless commenting experience with support for both Tailwind CSS and Bootstrap 5, making it easy for users to engage with your content. With features like comment sorting, pagination, reporting, emoji picker, and YouTube-style like/unlike buttons, this package is perfect for applications that require robust commenting capabilities. Additionally, guest users can like and unlike comments based on their IP addresses. Mentions can be used with "@" to tag specific users in replies and edits, while Markdown support allows for rich formatting in comments. Whether you're building a blog, an e-commerce platform, or any other type of web application, Commentify is a powerful tool for enhancing user engagement and collaboration.
config/commentify.php)IP & UserAgent)You can install the package via composer:
composer require usamamuneerchaudhary/commentify
The service provider is automatically discovered in Laravel 12+ when installed via Composer from Packagist.
However, if you're using a local development setup (e.g., path repository with symlinks) or need to manually register it, add it to bootstrap/providers.php:
<?php
return [
App\Providers\AppServiceProvider::class,
// ... other providers
Usamamuneerchaudhary\Commentify\Providers\CommentifyServiceProvider::class,
];
Note: For local development with symlinked packages, explicit registration in
bootstrap/providers.phpensures migrations and other package resources are loaded correctly.
Once the package is installed, you can run migrations:
php artisan migrate
# Publish configuration file
php artisan vendor:publish --tag="commentify-config"
# Publish views (choose one based on your CSS framework)
php artisan vendor:publish --tag="commentify-tailwind-views" # For Tailwind CSS
php artisan vendor:publish --tag="commentify-bootstrap-views" # For Bootstrap 5
# Publish Filament views (framework independent)
php artisan vendor:publish --tag="commentify-filament-views"
# Publish language files
php artisan vendor:publish --tag="commentify-lang"
# Publish migrations
php artisan vendor:publish --tag="commentify-migrations"
Note: Only publish views if you need to customize them. The package will automatically use the correct framework views based on your
css_frameworkconfig setting. If you publish views, they will override the package views and you'll need to manually update them when the package is updated.
This will publish commentify.php file in config directory. Here you can configure user route and pagination count etc.
Commentify supports both Tailwind CSS and Bootstrap 5. Choose your preferred framework in config/commentify.php:
'css_framework' => 'tailwind', // Options: 'tailwind' or 'bootstrap'
The package will automatically load the appropriate views based on your selection. You can switch frameworks at any time by updating the config value.
tailwind.config.js file (Tailwind only)If you're using Tailwind CSS, you can publish the package's tailwind.config.js file by running:
php artisan vendor:publish --tag="commentify-tailwind-config"
Commentify supports dark mode with three options: light, dark, and auto (system preference).
For Tailwind CSS v4: Ensure your main CSS file includes the dark mode variant:
@import "tailwindcss";
@custom-variant dark (&:where(.dark, .dark *));
Note: If you're using Livewire Flux, this is already included in your CSS.
For Bootstrap 5: Dark mode uses Bootstrap's built-in data-bs-theme="dark" attribute. No additional CSS configuration needed.
Configure your preferred theme mode in config/commentify.php:
'theme' => 'auto', // Options: 'light', 'dark', 'auto'
light - Always use light modedark - Always use dark modeauto - Follows system preference (default)The theme is applied automatically to the comment components based on your configuration.
All configuration options are available in config/commentify.php:
return [
'users_route_prefix' => 'users', // Route prefix for user profiles
'user_model' => \App\Models\User::class, // Use your app's User model for avatars and user-related logic
'pagination_count' => 10, // Number of comments per page
'css_framework' => 'tailwind', // 'tailwind' or 'bootstrap'
'comment_nesting' => true, // Enable/disable nested comments
'read_only' => false, // Enable read-only mode
'default_sort' => 'newest', // Default sort: 'newest', 'oldest', 'most_liked', 'most_replied'
'enable_sorting' => true, // Enable/disable sorting dropdown
'enable_reporting' => true, // Enable/disable comment reporting
'report_reasons' => [ // Predefined report reasons
'spam',
'inappropriate',
'offensive',
'other'
],
'require_approval' => false, // Require manual approval for comments before they appear
'theme' => 'auto', // Theme mode: 'light', 'dark', 'auto'
'enable_emoji_picker' => true, // Enable/disable emoji picker
'enable_notifications' => false, // Enable/disable notifications
'notification_channels' => ['database'], // Notification channels: 'database', 'mail', 'broadcast'
];
In your model, where you want to integrate comments, simply add the Commentable trait in that model.
For example:
use Usamamuneerchaudhary\Commentify\Traits\Commentable;
class Article extends Model
{
use Commentable;
}
Next, in your view, pass in the livewire comment component. For example, if your view file is articles/show.blade. php. We can add the following code:
<livewire:comments :model="$article"/>
HasUserAvatar trait in App\Models\User, to use avatars:use Usamamuneerchaudhary\Commentify\Traits\HasUserAvatar;
class User extends Model
{
use HasUserAvatar;
}
user_model in config/commentify.php so avatars and user-related logic load from your app's User model:'user_model' => \App\Models\User::class,
Commentify supports multiple sorting options for comments:
Users can change the sort order using the dropdown menu. Configure the default sort and enable/disable sorting in config/commentify.php:
'default_sort' => 'newest', // Default sort order
'enable_sorting' => true, // Show/hide sorting dropdown
Users can report inappropriate comments with predefined reasons. Configure reporting in config/commentify.php:
'enable_reporting' => true, // Enable/disable reporting
'report_reasons' => [ // Customize report reasons
'spam',
'inappropriate',
'offensive',
'other'
],
When "other" is selected, users can provide additional details. Reports are stored in the comment_reports table and can be managed through the Filament admin panel.
Note: Each user can only report a comment once to prevent abuse.
Commentify includes a built-in moderation system that allows you to require manual approval for comments before they appear on the frontend.
Configure comment approval in config/commentify.php:
'require_approval' => true, // Require manual approval for comments
When enabled:
is_approved = false)When disabled (default):
is_approved = true)When comment approval is enabled, administrators can approve or disapprove comments through the Filament admin panel:
You can also toggle comment approval on/off from the Commentify Settings page in Filament, without editing the config file manually.
Commentify includes an emoji picker for rich commenting. Enable or disable it in config/commentify.php:
'enable_emoji_picker' => true,
The emoji picker automatically adapts to your theme (light/dark mode) and works with both Tailwind CSS and Bootstrap.
Commentify supports notifications for comment events. Configure notifications in config/commentify.php:
'enable_notifications' => true,
'notification_channels' => ['database', 'mail', 'broadcast'],
See NOTIFICATIONS_SETUP.md for detailed setup instructions, including:
You can customize the views by publishing them:
# Publish Tailwind views
php artisan vendor:publish --tag="commentify-tailwind-views"
# Publish Bootstrap views
php artisan vendor:publish --tag="commentify-bootstrap-views"
Published views will be available in resources/views/vendor/commentify/ and can be customized as needed.
Note: Once views are published, they take precedence over package views. You'll need to manually update them when the package is updated.
All strings are translatable. Publish language files:
php artisan vendor:publish --tag="commentify-lang"
Then customize translations in lang/vendor/commentify/.
Temporarily disable all commenting (for maintenance, etc):
config/commentify.php:
'read_only' => true,
comment_banned_until column to your users table.HasCommentBan trait to your User model:
use Usamamuneerchaudhary\Commentify\Traits\HasCommentBan;
class User extends Authenticatable
{
use HasCommentBan;
}
comment_banned_until to a future date to block a user.lang/vendor/commentify.CommentPolicy.Commentify includes optional Filament admin panel integration for managing reports, comments, and settings.
composer require filament/filament:"^4.0"
php artisan filament:install --panels
app/Providers/Filament/AdminPanelProvider.php):use Usamamuneerchaudhary\Commentify\Filament\CommentifyPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugin(CommentifyPlugin::make());
}
This will automatically register:
Comments Management:
Comment Reports Management:
Settings Page:
See FILAMENT_SETUP.md for detailed setup instructions.
Run the test suite:
composer test
If you discover any security related issues, please email hello@usamamuneer.me instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
How can I help you explore Laravel packages today?