Download the PHP package x-laravel/commentable without Composer

On this page you can find all versions of the php package x-laravel/commentable. 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 commentable

Commentable for Laravel

Tests Latest Stable Version PHP Version Total Downloads License

Polymorphic, infinitely nested comments for Eloquent. Any model can receive comments, any model can post them, and commenters are optional, so anonymous comments work too. Replies are loaded only when asked for.

Requirements

Package version PHP Laravel
1.x 8.4+ 13

Installation

Publish the config to change the defaults:

Preparing the Models

Implement CanComment and use Commenter on the model that posts comments. Implement HasComments and use Commentable on every model that can receive them; only those models are accepted:

The commentable_id and commenter_id columns follow Laravel's morph key type, so set Schema::defaultMorphKeyType('uuid') or 'ulid' before migrating if your models use them.

Configuration

Key Default Meaning
connection null Connection of the comment table
comment.table 'comments' Name of the comment table
comment.model Comment::class Comment model; must extend the package's
prune.enabled true Schedule the pruning of left-behind comments
prune.schedule 'daily' A cron expression, or a frequency method with its arguments: 'dailyAt:03:30', 'twiceDaily:1,13', 'weeklyOn:1,04:00'
prune.chunk 1000 Rows deleted by each pruning query

Commenting

Replies can be added to any comment or reply, with no depth limit. A parent comment that belongs to another model is refused with InvalidArgumentException.

Listing

The relations load nothing extra by default; chain counts and relations as each screen needs them.

Comment keys are ULIDs, so they can appear in URLs without revealing how many comments exist.

Deleting and Pruning

Soft-deleting a comment leaves its replies in place. Add a deleting listener in your application if they should go with it.

When a commented model or a commenter is deleted, its comments are permanently deleted with it, soft-deleted ones included, and the foreign key takes their replies along, whoever wrote them. Soft-deleted models keep their comments until they are force deleted.

Deletes that skip model events, such as bulk queries, database cascades or raw SQL, leave comments behind. The package schedules model:prune, daily by default, to remove comments whose commented model or commenter no longer exists. Anonymous comments are kept. Run it by hand with:

Pruning skips types that no longer resolve to a model and models on another connection.

Reacting to Comments

XLaravel\Commentable\Events\Commented is dispatched for a new comment and Replied for a new reply; $event->comment->parent is the comment that was replied to. CommentDeleted is dispatched when a comment is soft or force deleted. All three carry the Comment and are dispatched after the surrounding transaction commits.

Comments removed together with their model or commenter, by the foreign key or by pruning dispatch nothing.

Testing

License

Open source software licensed under the MIT license.


All versions of commentable with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
illuminate/console Version ^13.0
illuminate/contracts Version ^13.0
illuminate/database Version ^13.0
illuminate/support Version ^13.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 x-laravel/commentable contains the following files

Loading the files please wait ...