roundly-consulting/comments-for-laravel
A drop-in comments system for Laravel. Add threaded, polymorphic comments to any Eloquent model with migrations, models, and a simple API, no third-party service required. Configurable and lightweight, it's ready to integrate into your app in minutes.
Architecture fit
This is a Laravel-native package that supplies an Eloquent-backed comments model plus a JsonResource API layer (CommentResource). It sits in the presentation/adapter layer of a typical Laravel app: the domain owns the Comment model and polymorphic actor/author relation, and the package owns serialization. That is a good architectural boundary — it means our API contract is shaped by a config key (comments.resources.author) rather than by our own transformers, so customization happens through Laravel's container/config conventions rather than forking the package.
The 1.2.0 addition (CommentAuthorResource) and the new config key strengthen this: the package now exposes an explicit extension point instead of forcing teams to subclass or override CommentResource wholesale. For a TPM this is the single most important signal in the release — it converts a likely fork into a supported configuration path.
Integration feasibility
Straightforward for any team already on Laravel with JsonResource in use. Composer install, publish config/migrations, and the default CommentAuthorResource::class means zero-config for new adopters. The InvalidConfigurationException on a non-instantiable/non-JsonResource value is fail-fast validation naming the offending key, which is the right behavior and cheap to test.
Technical risk
The Changed entry is effectively a breaking API contract change, even though it ships in a minor version:
author.type previously emitted the raw stored actor_type — on an app without a morph map that is the fully-qualified class name (App\Models\User). Clients that parse or switch on that string will break, and any client that persisted it will hold stale values.User), which is a genuine security/hygiene improvement (no internal namespace leakage) and a cleaner contract, but it is a silent wire-format change: no deprecation window, no version flag, no dual-emit.comments.resources.author key. If the package reads the key without a hardcoded fallback, upgrades could throw InvalidConfigurationException at boot. This needs verification, not assumption.CommentResource is resolved, that can surface as a 500 on a comments endpoint rather than at deploy time.Net: low-to-moderate risk. The change is well-motivated and the escape hatch exists (swap the resource), but it must be treated as a consumer-facing contract change requiring a comms step, not a routine patch bump.
Key questions
comments.resources.author fall back to the default, or throw? (Determines whether this is a safe patch or a required config migration.)author.type change documented as breaking in the changelog/UPGRADING notes, and is there a semver argument for 2.0.0?CommentAuthorResource handle null gracefully?Stack fit
Fits any Laravel app using Eloquent resources for API output. If our API is consumed by mobile or third-party clients, the author.type change is outward-facing and needs versioning discipline on our side regardless of what the package does.
Migration path
comments.resources.author => CommentAuthorResource::class so behavior does not depend on an implicit fallback./comments response payload in a contract test. The only expected delta should be author.type.comments.resources.author at a small app-owned JsonResource that restores the old shape, and treat that as a dated shim with a removal ticket.Compatibility
Watch the published-config gap: Laravel does not merge new keys into already-published config files. Confirm the fallback behavior before assuming a minor bump is drop-in. Also confirm that any app-level morphMap does not change the basename output in a way our consumers would notice, and that author.type remains stable for any model whose class basename we might rename later.
Sequencing
(a) Verify config fallback + eager loading → (b) upgrade in staging with contract test → (c) decide accept-vs-shim for author.type → (d) consumer comms if accepting → (e) production rollout behind the existing comments feature flag → (f) delete shim and close ticket. Keep the upgrade isolated from unrelated framework upgrades so any regression is attributable.
Maintenance Low ongoing cost: config-driven behavior, no fork, no patched vendor code. The main long-term liability is coupling our public API shape to a third-party package's serialization defaults — mitigated, but not eliminated, by the new config key. Budget a recurring line item for reading changelogs before minor bumps, since this release demonstrates that minor versions can carry wire-format changes.
Support
Support burden concentrates at two moments: the upgrade (config key, contract diff) and any consumer incident where author.type changed unexpectedly. Publish an internal note stating that author.type is a package-owned contract, so future debugging does not chase it as a bug in our code. The named-key exception message is good for self-service diagnosis; capture it in the runbook.
Scaling
Primary scaling concern is query count, not throughput: the author resource must resolve from an already-eager-loaded relation. If it lazy-loads per comment, a 50-comment page becomes 51 queries. Require with('actor') (or equivalent) in the consuming controller and assert query count in a test. Payload size is trivial and unchanged.
Failure modes
InvalidConfigurationException if the config key is absent or points at a non-JsonResource class — manifests as a 500 on comments endpoints.config:cache not re-run).App\Models\User → User.Ramp-up
Minimal. Any Laravel developer can read CommentResource, the config key, and a JsonResource subclass in under an hour. The non-obvious knowledge is procedural: published-config key merging, config:cache in the deploy step, and the fact that this package defines a public API contract. Put those three points in the onboarding doc rather than expecting them to be discovered.
How can I help you explore Laravel packages today?