PHPackages                             cgu2022/cs-278-extension - 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. cgu2022/cs-278-extension

ActiveFlarum-extension

cgu2022/cs-278-extension
========================

CS-278 Extension for Flarum

v2.0.2(1y ago)031MITPHP

Since Jun 6Pushed 1y ago1 watchersCompare

[ Source](https://github.com/cgu2022/cs-278-extension)[ Packagist](https://packagist.org/packages/cgu2022/cs-278-extension)[ RSS](/packages/cgu2022-cs-278-extension/feed)WikiDiscussions main Synced 1mo ago

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

cs-278-extension
================

[](#cs-278-extension)

A Flarum extension for my CS 278 project, Spring 2024.

All relevant files to the development of this extension are explained in the second section, and each of them contain insightful comments.

1. Setup Instructions
2. CS 278 UniForum Extension Description
3. Installing CS 278 Extension Instructions
4. Developing CS 278 Extension Instructions

---

Setup Instructions
------------------

[](#setup-instructions)

### Install OpenAI Community's PHP API Accessor Library

[](#install-openai-communitys-php-api-accessor-library)

To install the necessary dependencies, run the following command:

```
composer require openai-php/client guzzlehttp/guzzle
```

> Note: Ensure that PHP version 8.1 or above is already configured on your system for this to work.

### Download and Configure the CA Certificates\*

[](#download-and-configure-the-ca-certificates)

\*Note that you only need to do this step if you're doing localhost development or don't have a proper SSL signature. This is step is necessary for sending requests to OpenAI's API.

1. **Download the CA Certificates**:

- Download the `cacert.pem` file from [this link](https://curl.haxx.se/ca/cacert.pem).

2. **Configure PHP to Use the CA Certificates**:

- Locate your `php.ini` file (you can find its location by running `php --ini`).
- Open `php.ini` and add or update the following line to point to the downloaded `cacert.pem` file:

```
curl.cainfo = "C:\path\to\your\cacert.pem"
```

- Save the `php.ini` file and restart your web server.

---

CS 278 UniForum Extension Description
-------------------------------------

[](#cs-278-uniforum-extension-description)

---

### Overview

[](#overview)

**UniForum Extension**: This extension enhances Flarum by integrating OpenAI's GPT API to generate automated summaries of discussion threads. Users can click a button to request a summary of the conversation, which is then displayed to improve user experience by providing concise overviews of lengthy discussions.

### File Structure

[](#file-structure)

```
CS-278_EXTENSION
│ .gitignore
│ composer.json
│ extend.php
│ LICENSE
│ package-lock.json
│ README.md
│
├───js
│ ├───dist
│ │ admin.js
│ │ admin.js.map
│ │ forum.js
│ │ forum.js.map
│ │
│ └───src
│ ├───admin.js
│ └───forum.js
│
├───locale
│ en.yml
│
└───src
├───Api
│ ├───Serializer
│ │ SummarySerializer.php
│ │
│ ├───GenerateSummaryController.php
│ ├───api.php (empty)
│ └───extend.php (empty)
│
├───api.php
└───extend.php

```

File Summaries and Documentation
--------------------------------

[](#file-summaries-and-documentation)

#### `composer.json`

[](#composerjson)

**Description**: Composer configuration for PHP dependencies.

**Exposes**:

- Defines PHP dependencies required by the extension.
- Sets up autoloading for the `CGU2022\\CS278Extension` namespace.

---

#### `extend.php`

[](#extendphp)

**Description**: Main entry file to extend Flarum's functionality.

**Exposes**:

- Registers a POST route `/generate-summary` handled by `GenerateSummaryController`.

---

#### `api.php`

[](#apiphp)

**Description**: Defines API endpoints for the extension.

**Exposes**:

- Sets up the POST route `/generate-summary` for API interactions.

---

#### `SummarySerializer.php`

[](#summaryserializerphp)

**Description**: Serializes the summary data from GPT API responses.

**Exposes**:

- Converts the summary and full response from GPT API into JSON API format.

---

#### `GenerateSummaryController.php`

[](#generatesummarycontrollerphp)

**Description**: Handles requests to generate discussion summaries using the GPT API.

**Exposes**:

- Endpoint logic for `/generate-summary`.
- Collects discussion posts and sends them to the GPT API.
- Returns the summary and the full response.

---

#### `js/src/admin.js`

[](#jssrcadminjs)

**Description**: Registers admin settings for the extension.

**Exposes**:

- Provides a setting in the admin panel to enter the OpenAI API key.

---

#### `js/src/forum.js`

[](#jssrcforumjs)

**Description**: Extends the discussion page to add a "Generate Summary" button.

**Exposes**:

- Adds a button to the discussion page to trigger summary generation.
- Displays a loading indicator while the summary is being generated.
- Handles the API request to generate the summary.

---

Installing UniForum
-------------------

[](#installing-uniforum)

To install the extension, run the following command:

```
composer require cgu2022/cs-278-extension
```

To update the extension when a new version is released, run:

```
composer update
```

**NOTE**: If you are using a Docker image to deploy your UniForum instance, do not use the above commands directly. Instead, add the following line to your `docker_entrypoint.sh` file:

```
extension require cgu2022/cs-278-extension
```

This ensures that the extension is properly installed during the Docker container's initialization.

---

Developing UniForum
-------------------

[](#developing-uniforum)

Once you have completed the setup and familiarized yourself with the file structure, you can start developing UniForum.

1. **Prepare the Environment**:

    - Create a folder named "packages" in the root directory of your Flarum instance.
    - Run the following commands to set up the Composer repository and require the extension in development mode:

    ```
    composer config repositories.0 path "packages/*"
    composer require cgu2022/cs-278-extension *@dev
    ```
2. **Install JavaScript Dependencies**:

    - Navigate to the `js` folder and run the following commands:

    ```
    npm install
    npm run dev
    ```
3. **During Development**:

    - **EACH TIME YOU MAKE A CHANGE**:
        - Restart the web server.
        - Run `composer install` and `npm install` if necessary.
        - Relaunch the Node.js development environment by running `npm run dev` again.
        - Disable and then re-enable this extension in the Flarum *administrator* panel to apply changes.
4. **Check Dependencies**:

    - Ensure the `composer.json` file contains all necessary dependencies and configurations for your development environment.
5. **Contributing**:

    - Feel free to submit a pull request if you have any improvements or bug fixes for the extension. Contributions are welcome!

---

### Useful Links

[](#useful-links)

- [Flarum Documentation](https://docs.flarum.org/)
- [Flarum Extension Documentation](https://docs.flarum.org/extend)
- [Flarum API Documentation](https://api.docs.flarum.org/)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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 ~0 days

Total

12

Last Release

702d ago

Major Versions

v0.1.0 → v1.0.02024-06-07

v1.0.8 → v2.0.02024-06-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/ea0863a5bb4a2f2944f0f4ccfa6417f3e8ae011ef6b72fa20673eb11074ad424?d=identicon)[cgu26](/maintainers/cgu26)

---

Top Contributors

[![cgu2022](https://avatars.githubusercontent.com/u/44711033?v=4)](https://github.com/cgu2022 "cgu2022 (18 commits)")

### Embed Badge

![Health badge](/badges/cgu2022-cs-278-extension/health.svg)

```
[![Health](https://phpackages.com/badges/cgu2022-cs-278-extension/health.svg)](https://phpackages.com/packages/cgu2022-cs-278-extension)
```

###  Alternatives

[fof/upload

The file upload extension for the Flarum forum with insane intelligence.

188171.7k15](/packages/fof-upload)[fof/byobu

Well integrated, advanced private discussions.

61105.8k9](/packages/fof-byobu)[fof/gamification

Upvotes and downvotes for your Flarum community

4157.1k6](/packages/fof-gamification)[flarum/suspend

Suspend users so they can't post.

10404.5k16](/packages/flarum-suspend)[fof/user-bio

Add a user bio to user profiles

2196.5k9](/packages/fof-user-bio)[flarum/extension-manager

An extension manager to install, update and remove extension packages from the interface (Wrapper around composer).

12211.5k](/packages/flarum-extension-manager)

PHPackages © 2026

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