Download the PHP package editmode/laravel-comments without Composer

On this page you can find all versions of the php package editmode/laravel-comments. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-comments

Laravel Comments

Latest Version on Packagist Total Downloads

A customizable Laravel package to easily add comments and threaded discussions to any model — ideal for blog posts, user profiles, product reviews, or any other entity in your app.

Supports optional like/dislike reactions, nested replies, and is designed to integrate smoothly with Inertia/React or Blade.

Table of Contents

Installation

You can install the package via composer:

Quickstart

After installing the package, it's recommended that you create your own custom Comment model that extends the base model provided by the package. This gives you full flexibility to modify, extend, or customize comment behavior as needed.

1. Install the package

2. Publish the configuration file (optional but recommended):

2.5. Publish the migrations

The package includes migrations to create the comments and comment reactions tables.
You should publish them using:

🛑 Important: If you plan to use the like/dislike feature, make sure to also publish the config file first and enable it in config/comments.php by setting like_dislike_feature to true. Otherwise, the comment_reactions table will not be created during migration.

3. Create your own Comment model by extending the base comment model:

🚨 VERY IMPORTANT
For Laravel's polymorphic relationships to work automatically without manual configuration, your custom model must be named Comment. If you use any other name (like UserComment, PostComment, etc.), morph types like commentable_type will not resolve correctly unless you manually configure a morph map. Laravel automatically handles this when your model is named Comment.

4. Update your configuration file config/comments.php to use your custom Comment model:

This setup allows you to fully control how comments behave in your application while leveraging the core features provided by the package.


5. Attach a comment to a model

You can now attach comments to any model by using the HasComments trait on that model.

Then, to add a comment as the currently authenticated user:

Or explicitly pass a user:

This allows you to associate comments with any model that uses the HasComments trait.

Config

You can publish the config file with:

Like/Dislike Feature

You can optionally enable the like/dislike feature in the package config. To enable this feature:

  1. Set like_dislike_feature to true in config/comments.php.
  2. Add the HasReactions trait to your custom comment model.

Migrations

You can publish and run the migrations with:

Then run the migrations:

⚠️ The create_comment_reactions_table migration will be skipped unless the like_dislike_feature setting is enabled in your config/comments.php file. If you plan to use the like/dislike feature, make sure to publish the config first and set like_dislike_feature to true before running php artisan migrate.

Routes

You can register the package's routes by calling the macro in your routes/web.php:

This will automatically register routes like GET /comments, and if the like/dislike feature is enabled, also POST /comments/{comment}/react/{type} — where {type} must be either like or dislike.

By default, routes are prefixed with /comments. You can change this by passing a different base URL to Route::comments('your-prefix').

💡 See Development Tips for filtering the route list.

Published Routes:

Method URI Name
GET /{prefix}
POST /{prefix} comment.store
PATCH /{prefix}/{comment} comment.update
DELETE /{prefix}/{comment} comment.destroy
POST /{prefix}/{comment}/react/{type} comment.reaction.toggle

//: # () //: # ()

Development Tips

Filtering Routes

To list only the routes registered by this package:

This helps when debugging or inspecting how the package integrates into your app.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

//: # ()

//: # ()

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-comments with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0||^11.0||^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package editmode/laravel-comments contains the following files

Loading the files please wait ....