PHPackages                             newway/comments - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. newway/comments

ActiveLibrary

newway/comments
===============

v0.1(11y ago)157[1 issues](https://github.com/NewwayLibs/Comments/issues)MITPHPPHP &gt;=5.3.0

Since Nov 10Pushed 11y ago3 watchersCompare

[ Source](https://github.com/NewwayLibs/Comments)[ Packagist](https://packagist.org/packages/newway/comments)[ RSS](/packages/newway-comments/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Newway PHP comments
-------------------

[](#newway-php-comments)

### Installation

[](#installation)

**1) Require `newway/comments` in composer.json and run `composer update`.**

```
"require": {
    "newway/comments": "dev-master"
    ...
}

```

**2) Include "vendor/autoload.php" file to your project.**

```
include ("../vendor/autoload.php");

```

**3) Configurate database conection:**

```
Newway\Comments\Init::initDatabase(array(
      'driver' => 'mysql',
      'host' => 'localhost',
      'database' => 'database',
      'username' => 'username',
      'password' => 'password',
      'charset'   => 'utf8',
      'collation' => 'utf8_unicode_ci',
      'prefix'    => '',
  ));

```

**4) Create comments table:**

Run `Newway\Comments\Init::init()` once in any part of application, after `Newway\Comments\Init::initDatabase` method, to create comments table. You must run once this code, and delete it.

**5) Finaly create an instance of the class**

```
//create instance with standart parameters
$comments = new Newway\Comments\Comments::getInstance();

//or create instance with your configuration
$comments = new Newway\Comments\Comments::getInstance(
    array(
        'customMessages' => array(
            'required' => 'Field &laquo;:attribute&raquo; is required.',
            'attributes' => array(
                'user_name' => 'Nickname',
                'user_email' => 'Email',
            ),
        ),
        'createRules' => array(
            'user_email' => 'required',
        ),
        'updateRules' => array(
            'user_email' => 'required',
        ),
        'table' => 'comments_table'
    )
);

```

### Using

[](#using)

**Operations with comments**

Use `Newway\Comments\Comments` class for CRUD operations.

```
$comments = Comments::getInstance();

//Create new comment
$comments->create($id, [
    'content_type' => 'page',
    'content_id' => $pageId,
    'name' => 'newway',
    'email' => 'newway@newway.com',
    'body' => 'My text'
  ]);

//Read comment
$pageComments = $comments->getList($params);

//Update
$comments->update($id, $_POST);

//Delete
$comments->delete($id);

```

You can see saving or updating results:

```
try{
    $comments->edit($id, $_POST))
} catch (Newway\Comments\Exceptions\ValidationFailException $e) {
    $errors = $comments->getValidationErrors();
} catch (Newway\Comments\Exceptions\NewwayCommentsException $e) {
    $error = $comments->getError();
}

```

**Using comments admin panel**

To use package admin panel you must:

1. Include Bootstap and jQuery libraries to your page:

    //Bootstrap from Google

     //jQuery from Google &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
2. Init admin panel in the right place:

    //Generate admin HTML Newway\\Comments\\Init::initCommentsAdmin();

**Using standard comments template**

```
//Create objects
$c = new Newway\Comments\Comments();
$cTemplate = new Newway\Comments\CommentsTemplate();

//Render styles and HTML
$cTemplate->displayCss();
$cTemplate->display(
    $c->getList(
        array(
            'content_type' => 'page',
            'content_id' => 1,
            'status' => 1,
        )
    ),
    $messages,
    $validationResult
);

```

Not required variable $messages must be an array like \['type' =&gt; 'mesage'\]. Not required variable $validationResult must contain validation errors from Newway\\Comments\\Exceptions\\ValidationFailException.

**Create comments list/add page like here:**

```
$c = Newway\Comments\Comments::getInstance();
$cTemplate = new Newway\Comments\CommentsTemplate();
$messages = array();
$validationResult = array();
if (!empty($_POST)) {
    try {
        $c->create(
            array_merge(
                array(
                    'content_type' => $contentType,
                    'content_id' => $contentId,
                    'status' => 1
                ),
                $_POST
            )
        );
        $messages = array('success' => $c->getSuccess());
        $_POST = array();
    } catch (Newway\Comments\Exceptions\ValidationFailException $e) {
      $validationResult = $e->getErrors();
    }catch (Newway\Comments\Exceptions\NewwayCommentsException $e) {
      $messages['error'] = $e->getMessage();
    }
}
$cTemplate->displayCss();
$cTemplate->display(
    $c->getList(
        array(
            'content_type' => $contentType,
            'content_id' => $contentId,
            'status' => 1,
        )
    ),
    $messages,
    $validationResult
);

```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4207d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d71d9096f85a96307a91e8debf8408c91c3cd6bfae629f0d0628071777c539e?d=identicon)[yaapis](/maintainers/yaapis)

---

Top Contributors

[![roman-slobodzian](https://avatars.githubusercontent.com/u/7092952?v=4)](https://github.com/roman-slobodzian "roman-slobodzian (37 commits)")[![yaapis](https://avatars.githubusercontent.com/u/390195?v=4)](https://github.com/yaapis "yaapis (4 commits)")

### Embed Badge

![Health badge](/badges/newway-comments/health.svg)

```
[![Health](https://phpackages.com/badges/newway-comments/health.svg)](https://phpackages.com/packages/newway-comments)
```

###  Alternatives

[livewire/livewire

A front-end framework for Laravel.

23.5k75.5M1.8k](/packages/livewire-livewire)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[wendelladriel/laravel-validated-dto

Data Transfer Objects with validation for Laravel applications

759569.4k13](/packages/wendelladriel-laravel-validated-dto)[laragear/two-factor

On-premises 2FA Authentication for out-of-the-box.

339785.3k8](/packages/laragear-two-factor)[yajra/laravel-datatables-editor

Laravel DataTables Editor plugin for Laravel 5.5+.

1186.1M2](/packages/yajra-laravel-datatables-editor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
