PHPackages                             litemerafrukt/postcomments - 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. [Framework](/categories/framework)
4. /
5. litemerafrukt/postcomments

ActiveLibrary[Framework](/categories/framework)

litemerafrukt/postcomments
==========================

litemerafrukt postcomments module.

1.1.0(8y ago)022MITPHPPHP &gt;=7.0

Since Oct 8Pushed 8y ago1 watchersCompare

[ Source](https://github.com/litemerafrukt/postcomments)[ Packagist](https://packagist.org/packages/litemerafrukt/postcomments)[ Docs](http://litemerafrukt.se)[ RSS](/packages/litemerafrukt-postcomments/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

Anax postcomments
=================

[](#anax-postcomments)

[![Latest Stable Version](https://camo.githubusercontent.com/9e0343f2230058fa7807f1e4a8ecbf2e168f66b6da93a5e3964bc8c34dd6ffd5/68747470733a2f2f706f7365722e707567782e6f72672f6c6974656d6572616672756b742f706f7374636f6d6d656e74732f762f737461626c65)](https://packagist.org/packages/litemerafrukt/postcomments)[![Build Status](https://camo.githubusercontent.com/134d0d077f1a2fce85f65f2b6a9b165939377fa35f8da7a7fed18eed00d61e66/68747470733a2f2f7472617669732d63692e6f72672f6c6974656d6572616672756b742f706f7374636f6d6d656e74732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/litemerafrukt/postcomments)[![CircleCI](https://camo.githubusercontent.com/dc30f0c506a08c6957555fab15c3dda6da8052c8d57149d6781d8f5604ecb639/68747470733a2f2f636972636c6563692e636f6d2f67682f6c6974656d6572616672756b742f706f7374636f6d6d656e74732e7376673f7374796c653d737667)](https://circleci.com/gh/litemerafrukt/postcomments)[![Build Status](https://camo.githubusercontent.com/abfb52d28ede20165d87ab2a57260bdc8f9b2fe2d70019b6e7d177707162d18d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c6974656d6572616672756b742f706f7374636f6d6d656e74732f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/litemerafrukt/postcomments/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/961839591b5834cf4981fdaadac96a518174232cd9fe630e8f6534e8d46c0782/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c6974656d6572616672756b742f706f7374636f6d6d656e74732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/litemerafrukt/postcomments/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/a2b2add2933d9f165b61089099134070036eed9544e215659de5295324e9e919/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c6974656d6572616672756b742f706f7374636f6d6d656e74732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/litemerafrukt/postcomments/?branch=master)

[![](https://camo.githubusercontent.com/e9e9cbb0e28fc6929d550cc9f747f7bf395bc9ae03434c8acbf916c75bd0aec9/68747470733a2f2f636f64657363656e652e696f2f70726f6a656374732f313734392f7374617475732e737667)](https://codescene.io/projects/1749/jobs/latest-successful/results)

---

Reddit-like comments to posts.

Uses view-files recursively to achieve nested comments. There are default view files. If you want to define your own views then look at the included view files for examples. The `Comments` class takes a top level view file as optional parameter.

`CommentsHandler` class needs a simple database class with a `query`-method. Look at the supplied `Database` class for the interface if you want to build your own (which you should). The database needs to be setup with a comments table, se `src/extras` folder for schema. Table name can optionally be supplied to `CommentsHandler` constructor, defaults to `r1_comments`.

This module is built to fit in an [Anax](https://github.com/canax) project but should fit in to any project with a little work. At the same time, this is not a fit all package, this is written for a specific project.

Install
-------

[](#install)

PHP version &gt; 7.0.

`$ composer require litemerafrukt/postcomments`

Setup your database with a table for the commments, see `vendor/litemerafrukt/postcomments/src/extras`.

Use database class with namespace `litemerafrukt\Database` or supply your own class with a query-metod, see `vendor/litemerafrukt/postcomments/src/Database/Database.php` for interface.

Usage
-----

[](#usage)

Set up your forum post controller to handle both get and post requests. The postcomments module will supply the view with html for the comments.

Example from an Anax project.

```
class PostController

    /**
     * Show a post
     *
     * @param int $postId
     */
    public function showPost($id)
    {
        $post = $this->posts->fetch($id);

        $user = $this->di->get('user');
        $user->isUser = $user->isLevel(UserLevels::USER);
        $user->isAdmin = $user->isLevel(UserLevels::ADMIN);

        $comments = new Comments(new CommentHandler($this->di->get('olddb')));

        if ($this->di->request->getPost('new-comment-submitted', false) && $user) {
            $authorId = $user->id;
            $authorName = $user->name;
            $parentId = $this->di->request->getPost('parent-id', 0);
            $text = \trim($this->di->request->getPost('comment-text'));
            $comments->new($id, $parentId, $authorId, $authorName, $text);

            $this->di->get("response")->redirectSelf();
        } else if ($this->di->request->getPost('edit-comment-submitted', false) && $user) {
            $id = $this->di->request->getPost('comment-id', null);
            $text = \trim($this->di->request->getPost('comment-text', ''));
            $comments->update($id, $text, function ($comment) use ($user) {
                return $comment['id'] === $user->id;
            });

            $this->di->get("response")->redirectSelf();
        }

        $commentsHTML = $comments->getHtml($id, $user->isUser, $user->isAdmin, $user->name, $user->id);

        $this->renderPage("posts/post", $post->subject, \compact('post', 'user', 'commentsHTML'));
    }

    ..
```

License
-------

[](#license)

This software carries a MIT license.

```
 .
..:  Copyright (c) 2017 Anders Nygren (litemerafrukt@gmail.com)

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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

Every ~2 days

Total

4

Last Release

3129d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.6

1.0.1PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/69c307bf931e5b3fddc517208cb3a347fac91876991d71b6e1472967095762e3?d=identicon)[litemerafrukt](/maintainers/litemerafrukt)

---

Top Contributors

[![litemerafrukt](https://avatars.githubusercontent.com/u/16654263?v=4)](https://github.com/litemerafrukt "litemerafrukt (15 commits)")

---

Tags

frameworkmicromvcboilerplateeducation

### Embed Badge

![Health badge](/badges/litemerafrukt-postcomments/health.svg)

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

PHPackages © 2026

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