Download the PHP package tizis/lara-comments without Composer

On this page you can find all versions of the php package tizis/lara-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 lara-comments

README на русском

laraComments

This package can be used to comment on any model you have in your application.

Features

Upgrade guides →

Requirements

Installation

1. Run migrations

We need to create the table for comments.

2. Add Commenter trait to your User model

Add the Commenter trait to your User model so that you can retrieve the comments for a user:

3. Create Comment model

4. Add Commentable trait and the ICommentable interface to models

Add the Commentable trait and the ICommentable interface to the model for which you want to enable comments for:

5. Custom comment policy (optional)

If you need, you can overwrite default comment policy class:

Then register policy in AuthServiceProvider:

And add policy prefix to comments.php config

Publish Config & configure (optional)

In the config file you can specify:

Publish the config file (optional):

Publish views (customization)

The default UI is made for Bootstrap 4, but you can change it however you want.

⚠⚠⚠⚠WARNING⚠⚠⚠⚠

All view examples include js/css files for correct working. The possibility of conflict with your scripts and styles.

Usage

1. Backend rendering:

In the view where you want to display comments, place this code and modify it:

In the example above we are setting argument the model as class of the book model.

Behind the scenes, the package detects the currently logged in user if any.

If you open the page containing the view where you have placed the above code, you should see a working comments form.

2. Frontend rendering (API):

Title Method Url Params Route name
Get comments GET /api/comments/ commentable_encrypted_key, order_by (column name, default is id), order_direction (default is asc) route('comments.get')
Store comment POST /api/comments/ commentable_encrypted_key, message route('comments.store')
Delete comment DELETE /api/comments/{comment_id} -- route('comments.delete', $comment_id)
Edit comment POST /api/comments/{comment_id} message route('comments.update', $comment_id)
Reply to comment POST /api/comments/{comment_id} message route('comments.reply', $comment_id)
Vote to comment POST /api/comments/{comment_id}/vote vote(bool) route('comments.vote', $comment_id)

3. Access to the comment service

If you don't want use out of the box features: API, or the CommentController, but want to access the built-in features - you can use tizis\laraComments\UseCases\CommentService

CommentService class used inside default comment controller for request processing.

To disable API routes by default, set the route.root => null config value.

Methods:

  1. Сreate comment: CommentService::createComment

    1. Delete comment: CommentService::deleteComment
  2. Update comment: CommentService::updateComment

Events

This package fires events to let you know when things happen.

API preprocessing

WARNING! Only for API!

Supported preprocessors for attributes of get api:

1. Description

Sometimes additional processing of content is necessary before transmission over API.

2. Config:

3. Contract

Create preprocessor class and implement ICommentPreprocessor interface:

Examples:

Comment:

User:

4. Example:

Without preprocessing:

With preprocessing:

Features of Commentable model

Example:

Static Helper

use tizis\laraComments\Http\CommentsHelper;

Methods:

Example:

Examples

This repository include only bootstrap4 template, but you can create you own UI. This is just a example of package features.

This is example of backendrendering, this way have bad performance when 100+ comments on post due to the need to check user permissions (reply, edit, delete etc) for each comment.

A good idea is use API and build UI with Vue js (or any other library) with verification of user permissions (only for UI) on frontend.

  1. Build with bootstrap 4
    3333

Upgrade guides

From 2.x.x to 3.0

commentable_type and commentable_id request attributes was merged into single

You need to replace these deprecated attributes.

Example:


All versions of lara-comments with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1|^8.0
illuminate/support Version ~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0
illuminate/database Version ~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0
illuminate/http Version ~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0
mews/purifier Version ^2.1|^3.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 tizis/lara-comments contains the following files

Loading the files please wait ....