PHPackages                             davor/news-recommendation - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. davor/news-recommendation

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

davor/news-recommendation
=========================

This package provides AI generated recommendation tags for articles and stores them

v2.04(1y ago)0150MITPHPPHP ^7.2|^8.0

Since Aug 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/hollander-davor/news-recommendation)[ Packagist](https://packagist.org/packages/davor/news-recommendation)[ RSS](/packages/davor-news-recommendation/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (60)Used By (0)

News-recommendation
===================

[](#news-recommendation)

Installation:
-------------

[](#installation)

1. composer require davor/news-recommendation
2. php artisan vendor:publish --tag=config --provider="Hoks\\NewsRecommendation\\NewsRecommendationServiceProvider"
3. Set up config/newsrecommendation.php
4. Set up connection for mongodb in config/database.php ```
        'mongodb' => [
                'driver'   => 'mongodb',
                'host'     => env('DB_HOST_MONGO', 'mongo'),
                'port'     => env('DB_PORT_MONGO', 27017),
                'database' => env('DB_DATABASE_MONGO', 'mongo'),
                'username' => env('DB_USERNAME_MONGO'),
                'password' => env('DB_PASSWORD_MONGO'),
                'options'  => [
                    'database' => env('DB_AUTH_DATABASE', 'admin'), // Authentication database
                ],
            ],
    ```
5. Shedule job on desired interval ```
        $schedule->job(new ProcessReaders())->everyThirtyMinutes();
    ```
6. Set up Redis to take data from user (see example bellow)
7. Use package :D

NOTE: Version 2.00 includes option to proces readers using python multithread. You must have python on server as well as redis and pymongo installed. Set 'use\_python' in config to true, and follow instructions there (run command "php artisan generate:config-json")

OpenAI
======

[](#openai)

This part of package is intended for communication with OpenAI.

Code example
------------

[](#code-example)

```
/**
 * This example shows how to ask OpenAI to create prompt for creating OpenAI image
 */

//using facade we create client and specify uri for OpenAI API
$askClient = \OpenAI::client('chat/completions');
//we ask for prompt (note that we use ['content'] to retrieve prompt)
$imagePrompt = $askClient->ask('Write best prompt for creating poster of Novak Djokovic being the best tennis player ever')['content'];
//using facade we create ampther client for image
$imageClient = \OpenAI::client('images/generations',60,'dall-e-3');
//we retrieve image url (by default)
$imageUrl = $imageClient->generateImage($imagePrompt)[0];
```

Set up Redis to take data from user
===================================

[](#set-up-redis-to-take-data-from-user)

This is example on how to take user data and store it in Redis

Code example
------------

[](#code-example-1)

### Set up route

[](#set-up-route)

```
Route::post('/reader', [FrontendController::class, 'readerData'])->name('reader');
```

### Write method in controller

[](#write-method-in-controller)

```
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Carbon;

public function readerData(){
    $redisKeys = Redis::keys('*');

    $data = request()->validate([
        'article_id' => ['required','numeric','exists:articles,id'],
        'readerID' => ['required','string'],
        'publish_at' => ['required','date']

    ]);
    $publishDate = Carbon::parse($data['publish_at']);
    // only take into account articles that are not older than 10 days
    if($publishDate > now()->subDays(10)){
        //extract reader string from redis and update it
        $readerData = Redis::get('reader-'.$data['readerID']);
        if($readerData){
            Redis::append('reader-'.$data['readerID'],'|'.$data['article_id']);
        }else{
            Redis::set('reader-'.$data['readerID'],$data['article_id']);
        }
    }

}
```

### Write script on blade.php that will create user id and make ajax

[](#write-script-on-bladephp-that-will-create-user-id-and-make-ajax)

```

    function generateUUID() {
        // Get current time in milliseconds
        var d = new Date().getTime();

        // Define the UUID template with placeholder characters
        var uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";

        // Replace the placeholders with random hexadecimal digits
        uuid = uuid.replace(/[xy]/g, function(c) {
            // Generate a random number between 0 and 15
            var r = (d + Math.random()*16)%16 | 0;

            // Update value of d for the next placeholder
            d = Math.floor(d/16);

            // Convert the number to a hexadecimal digit and return it
            return (c=="x" ? r : (r&0x3|0x8)).toString(16);
        });

        return uuid+'-'+{{$article['id']}};
    }

    $(document).ready(function() {
        const reader = localStorage.getItem("reader");
        var readerID;
        // if there is reader take data
        if(reader){
            readerID = reader;
        }else{
            //generate readerID
            readerID = generateUUID();
            localStorage.setItem("reader",readerID);
        }
        console.log(readerID);
        $.ajax({
            type: "POST",
            url: "{{route('frontend.ajax.reader')}}",
            data: {
                _token: "{{ csrf_token() }}",
                article_id: {{$article['id']}},
                readerID : readerID,
                publish_at : "{{$article['publish_at']}}"

            }
        });

    });

```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance46

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.3% 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 ~4 days

Total

59

Last Release

404d ago

Major Versions

v0.70 → v1.002025-02-06

v1.04 → v2.002025-04-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/c87880cf0cc441df57fc0bd2c404e4491194ae8dfaeb947aaea5570cdba6ecc0?d=identicon)[davor.holender](/maintainers/davor.holender)

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

---

Top Contributors

[![Lazar0405](https://avatars.githubusercontent.com/u/179207998?v=4)](https://github.com/Lazar0405 "Lazar0405 (12 commits)")[![hollander-davor](https://avatars.githubusercontent.com/u/174630875?v=4)](https://github.com/hollander-davor "hollander-davor (1 commits)")

### Embed Badge

![Health badge](/badges/davor-news-recommendation/health.svg)

```
[![Health](https://phpackages.com/badges/davor-news-recommendation/health.svg)](https://phpackages.com/packages/davor-news-recommendation)
```

###  Alternatives

[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

22.8k69.3k](/packages/grumpydictator-firefly-iii)[bagisto/bagisto

Bagisto Laravel E-Commerce

26.2k161.6k7](/packages/bagisto-bagisto)[unopim/unopim

UnoPim Laravel PIM

9.4k1.8k](/packages/unopim-unopim)[blair2004/nexopos

The Free Modern Point Of Sale System build with Laravel, TailwindCSS and Vue.js.

1.2k2.3k](/packages/blair2004-nexopos)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)

PHPackages © 2026

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