PHPackages                             tigo/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. tigo/recommendation

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

tigo/recommendation
===================

collaborative filtering recommender systems

v0.0.2(5y ago)869.5k14[2 issues](https://github.com/tigoCaval/recommendation-algorithm/issues)MITPHPPHP &gt;=7.0

Since Jan 28Pushed 4y ago2 watchersCompare

[ Source](https://github.com/tigoCaval/recommendation-algorithm)[ Packagist](https://packagist.org/packages/tigo/recommendation)[ Fund](https://www.paypal.com/donate?hosted_button_id=S7FBV5N6ZTRXQ)[ RSS](/packages/tigo-recommendation/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Recommendation algorithm
========================

[](#recommendation-algorithm)

Collaborative filtering recommendation system

- Ranking algorithm using likes / dislikes or star-based rating
- This package can be used in any PHP application or with any framework.
- Download package: `composer require tigo/recommendation`
- MIT license. ***Feel free to use this project***. ***Leave a star ⭐ or make a fork !***

*If you found this project useful, consider making a donation to support the developer.*

[![paypal](https://camo.githubusercontent.com/1c212254bf14c516a7571bbb8b8a1679967080453a6ba3a222491e973b6877dd/68747470733a2f2f7777772e70617970616c6f626a656374732e636f6d2f70745f42522f42522f692f62746e2f62746e5f646f6e61746543435f4c472e676966)](https://www.paypal.com/donate?hosted_button_id=S7FBV5N6ZTRXQ)| [![paypal](https://camo.githubusercontent.com/e1ff554a09e8e92bef25abc553ff05b88f45afd695877cf12f3a46558ef65b2e/68747470733a2f2f7777772e70617970616c6f626a656374732e636f6d2f656e5f55532f692f62746e2f62746e5f646f6e61746543435f4c472e676966)](https://www.paypal.com/donate?hosted_button_id=PPDESEV98R8KS)

[![](https://github.com/tigoCaval/images/raw/main/web/recommend.gif)](https://github.com/tigoCaval/recommendation-algorithm)

### Getting started

[](#getting-started)

Starting with composer

1. Install composer
2. Download package: `composer require tigo/recommendation`
3. PHP &gt;= 7.0; Versions that have been tested: 7.2.25, 7.3.23 e 8.0.1.

```
//Somewhere in your project, you may need to use autoload
include __DIR__ ."/vendor/autoload.php";
```

### Algorithms

[](#algorithms)

- ranking
- euclidean
- slope one

### Introduction

[](#introduction)

Recommend a product using collaborative filtering

```
   /**
     $table gets the array from the database.
     $user is the foreign key that represents the user who will receive the recommendation.
   **/
   use Tigo\Recommendation\Recommend; // import class
   $client = new Recommend();
   $client->ranking($table,$user); //optional third parameter refers to the score not accepted
   $client->euclidean($table,$user); //optional third parameter refers to the minimum accepted score
   $client->slopeOne($table, $user); //optional third parameter refers to the minimum accepted score
```

### Configuration

[](#configuration)

Sometimes, it may be necessary to rename the value of the constants (According to your database table).

[![example](https://github.com/tigoCaval/images/raw/main/web/table_r1.jpg)](https://github.com/tigoCaval/recommendation-algorithm)

- Configure: standard key (Directory: `./src/configuration/StandardKey.php`)

```
    const SCORE = 'score'; //score
    const PRODUCT_ID = 'product_id'; //Foreign key
    const USER_ID = 'user_id'; //Foreign key
```

### Example

[](#example)

A simple didactic demonstration of the algorithm

```
  /**
     Example using "rating: liked and disliked"
     like: score = 1;  dislike: score = 0
  **/
   $table = [
        ['product_id'=> 'A',
         'score'=> 1,
         'user_id'=> 'Pedro'
        ],
        ['product_id'=> 'B',
         'score'=> 1,
         'user_id'=> 'Pedro'
        ],
        ['product_id'=> 'A',
         'score'=> 1,
         'user_id'=> 'João'
        ],
        ['product_id'=> 'B',
         'score'=> 1,
         'user_id'=> 'João'
        ],
        ['product_id'=> 'C',
         'score'=> 1,
         'user_id'=> 'João'
        ]
  ];
  use Tigo\Recommendation\Recommend; // import class
  $client = new Recommend();
  print_r($client->ranking($table,"Pedro")); // result = ['C' => 2]
  print_r($client->ranking($table,"Pedro",1)); // result = [];

  print_r($client->euclidean($table,"Pedro")); // result = ['C' => 1]
  print_r($client->euclidean($table,"Pedro", 2)); // result = [] ;

  print_r($client->slopeOne($table,'Pedro')); // result = ['C' => 1]
  print_r($client->slopeOne($table,'Pedro', 2)); // result = []
```

### Supporting this project

[](#supporting-this-project)

If you are interested in supporting this project, you can help in many ways. Leave a star ⭐ or make a donation of any value.

### Sponsor supporting this project

[](#sponsor-supporting-this-project)

- \[\]

### Contributors

[](#contributors)

- [Tiago A C Pereira](https://github.com/tigoCaval)
- [list of contributors](https://github.com/tigoCaval/recommendation-algorithm/graphs/contributors)

### License

[](#license)

MIT license. See the archive [License](https://github.com/tigoCaval/recommendation-algorithm/blob/main/LICENSE)

---

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

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

Total

2

Last Release

1946d ago

### Community

Maintainers

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

---

Top Contributors

[![tigoCaval](https://avatars.githubusercontent.com/u/19934116?v=4)](https://github.com/tigoCaval "tigoCaval (47 commits)")

---

Tags

collaborative-filteringeuclidean-algorithmphpranking-algorithmrecommendation-algorithmrecommenderrecommender-systemslope-onerecommendationrecommendation systemrecommendercollaborative filteringrecommender systemeuclidean distancerecommendation algorithmslope one

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[phpdocumentor/reflection-docblock

With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.

9.4k741.0M1.5k](/packages/phpdocumentor-reflection-docblock)[rubix/ml

A high-level machine learning and deep learning library for the PHP language.

2.2k1.5M28](/packages/rubix-ml)[phpjuice/slopeone

PHP implementation of the Weighted Slope One rating-based collaborative filtering scheme.

858.7k](/packages/phpjuice-slopeone)[phpjuice/opencf

PHP implementation of the (Weighted Slopeone,Cosine, Weighted Cosine) rating-based collaborative filtering schemes.

965.3k](/packages/phpjuice-opencf)[amranidev/laracombee

Recommendation system for laravel

11537.9k1](/packages/amranidev-laracombee)[antoineaugusti/laravel-easyrec

A Laravel wrapper for the recommendation system Easyrec

552.3k1](/packages/antoineaugusti-laravel-easyrec)

PHPackages © 2026

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