Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Comments Laravel Package

lakm/laravel-comments

Commenter is a feature-rich Laravel package for adding a complete commenting system to your app. Drop in the x-comments Blade component for any model, and manage comments with the included admin panel, themes, and moderation features.

View on GitHub
Deep Wiki
Context7

Getting Started

Check your Livewire version before you run composer require. As of 4.1.0 the package requires Laravel 11/12/13, PHP 8.3+, and Livewire v4 — 4.1.0 explicitly dropped PHP 8.1/8.2, Laravel 10, and Livewire v3. If your app is still on Livewire 3, this is the single decision that determines whether you can use the current release at all.

composer require lakm/laravel-comments -W   # -W lets Composer move Livewire to v4 if needed
php artisan commenter:install               # publishes config, migrations, assets
php artisan migrate

Then wire up both sides of the relationship — the package is polymorphic, so any model can be commentable and any model can be a commenter:

use LakM\Commenter\Concerns\Commentable;
use LakM\Commenter\Contracts\CommentableContract;

class Post extends Model implements CommentableContract
{
    use Commentable;
}

Repeat with Commenter / CommenterContract on User. Add @commenterStyles in <head> and @commenterScripts before </body>, then drop the component in a view:

<x-commenter::index :model="$post" />

Where to look first: the GitBook docs (lakm.gitbook.io/commenter) — the README's Overview section shows a stale <x-comments :model="$post" /> snippet that will not resolve; the Quick Start form with the :: namespace is the correct one. Second stop is the published config file from commenter:install, which is where auth-vs-guest mode and theme selection live. Third is the demo repo (laravel-comments-demo) — faster than the docs for seeing the full layout wiring.

First use case: a blog post detail page. One line replaces an entire bespoke comment system — editor, threading, reactions, pagination, moderation hooks.

Implementation Patterns

Decide auth vs guest mode at install time, not later. The two are mutually exclusive per the feature list. Guest mode brings its own spam prevention and (since 2.0.0) email verification — which means mail deliverability becomes part of your commenting feature, so confirm your mailer is configured in staging before launch. Auth mode gives you reacted-users lists and mention functionality that guest mode doesn't.

Treat the component as a black box on the page. Everything after first render is Livewire. That means: don't wrap it in a Turbo/HTMX partial that swaps the DOM, don't put it inside a page-cache fragment, and don't assume a full page reload resets it. If your layout already runs Livewire, the component inherits your Livewire setup — nothing extra to wire.

Use the trait relations for read paths. For index pages that show comment counts, eager-load from the Commentable trait's relation rather than letting each row hydrate independently. The component handles its own pagination; your listing page should not duplicate that query.

Themes over CSS surgery. Assets ship precompiled (Tailwind v4 since 4.0.0). Switch themes per the docs rather than editing package styles — put any tweaks in a small app-level override stylesheet loaded after @commenterStyles, and keep view overrides in resources/views/vendor/commenter if you must change markup.

Admin panel is a separate install. lakm/laravel-comments-admin-panel is its own repo/package. If you already run Filament or Nova, weigh that against a second admin surface — you can build moderation into your existing panel against the package's models instead.

Feature surface you should not rebuild: threaded replies (3.0.0), pinning (4.0.0), reactions, mentions, dark mode, filtering/sorting. All are shipped UI. Your job is embedding, theming, and moderation policy — not reimplementing comment UX.

Gotchas and Tips

  • The :: is load-bearing. <x-commenter::index> resolves the package component; <x-commenter> (or <x-comments>) makes Laravel look in your own resources/views/components and fails confusingly. The README explicitly warns about this, and its own Overview section then violates it.
  • Major-version churn is real. 2.0 → 3.0 → 4.0 → 4.1 landed in quick succession with breaking changes to PHP, Laravel, and Livewire support. Pin an exact version in composer.json, and read the CHANGELOG before any minor bump — 4.1.0 alone dropped three platform versions.
  • Migration ordering. Fixed in 4.1.0 (PR #181), but on 4.0.x published migrations can land in the wrong order relative to your users table. On a fresh install, migrate after your own user migration; if ordering looks wrong, rename the published timestamps.
  • Broken styles usually mean assets, not CSS. The Vite-manifest-absolute-path bug and asset build timeout were both patched in 4.1.0. If styles vanish after an upgrade, re-publish assets (commenter:install --force or vendor:publish) and clear caches before touching any CSS.
  • php artisan config:clear after mode changes. Switching auth/guest or theme goes through the published config; a cached config in staging will silently ignore your edit.
  • Missing-attribute exceptions were fixed in 4.0.2 — if you're pinned below that and see them, check that your commenter model actually implements CommenterContract and not just the trait.
  • Rate-limit guest comments at the edge too. Built-in spam prevention is good, but add server-level throttling on the comment endpoint; guest mode with email verification is a spam magnet if the mailer is a no-op in staging.
  • Rendering comments outside the component (emails, exports, admin previews) bypasses the package's escaping. Sanitize the WYSIWYG HTML yourself on those paths.
  • Ecosystem risk is the honest headline. Zero dependents, effectively a single maintainer, and a UI hard-bound to Livewire. Pin the version, budget for a quarterly upgrade check, and keep the exit cost low — the comment data is in your database, but replacing the UI means replacing the whole Livewire surface. For a marketing site or a blog this is an easy trade; for a core product feature, treat it as a real dependency with a maintenance owner.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table