PHPackages                             aldeebhasan/laravelcf - 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. aldeebhasan/laravelcf

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

aldeebhasan/laravelcf
=====================

This package will allow you to make fast recommendation based on custom inputs

1.0.3(2y ago)3111MITPHPPHP &gt;=8.1

Since Jun 10Pushed 2y ago1 watchersCompare

[ Source](https://github.com/aldeebhasan/LaravelCF)[ Packagist](https://packagist.org/packages/aldeebhasan/laravelcf)[ RSS](/packages/aldeebhasan-laravelcf/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

Laravel Recommendation system (LaravelCF)
=========================================

[](#laravel-recommendation-system-laravelcf)

A php package allow you to find the est recommendation of your modules

Installation
------------

[](#installation)

Install using composer:

```
composer require aldeebhasan/laravelcf
```

The run :

```
php artisan migrate
```

Basic Usage
-----------

[](#basic-usage)

LarvelCF package allow you to recommend data based on many algorithms including (Cosine,Weighted Cosine, Centered Cosine, SlopeOne).

In general we have two kind of recommender included in this package:

- item-based recommender
- user-based recommender

Filling the data
----------------

[](#filling-the-data)

The first step to build your recommendation system is to provide the dataset you want to work with.

In LarvelCF we have 4 type of data (PURCHASE, RATE, CART\_ACTION, BOOKMARK). the purpose of these types is to enable you to handle different types of data at the same time.

You can use the following to enter your recommender data:

```
use \Aldeebhasan\LaravelCF\Facades\Recommender;

Recommender::addRating      ('user_1', 'product_1', 5);
Recommender::addCartAddition('user_1', 'product_1', 2); // like the quantity
Recommender::addPurchase    ('user_1', 'product_1', 5); // like the quantity
Recommender::addBookmark    ('user_1', 'product_1', 5);
```

Instantiate the recommender
---------------------------

[](#instantiate-the-recommender)

After entering your data, you can instantiate your desired recommender using our support facade:

```
use \Aldeebhasan\LaravelCF\Facades\Recommender;
use \Aldeebhasan\LaravelCF\Enums\RelationType;

/* you cann also use any of RelationType::PURCHASE,RelationType::CART_ACTION,RelationType::BOOKMARK*/
Recommender::getItemBasedRecommender(RelationType::RATE); // to recommend similar products
//OR
Recommender::getUserBasedRecommender(RelationType::RATE);// to recommend similar users
```

Get recommendations
-------------------

[](#get-recommendations)

Finally, to make your recommendations you will run the following code:

```
use \Aldeebhasan\LaravelCF\Facades\Recommender;
use \Aldeebhasan\LaravelCF\Enums\RelationType;

/* you cann also use any of RelationType::PURCHASE,RelationType::CART_ACTION,RelationType::BOOKMARK*/
Recommender::getItemBasedRecommender(RelationType::RATE)
            ->setSimilarityFunction(Cosine::class)
            ->train()
            ->recommendTo('user_1');
```

For the `setSimilarityFunction`, you can provide the similarity algorithm, the missing value default values, and weather you want to fill the missing methods or discard them.

Available Similarity algorithm:

- Cosine::class (default for item-based)
- CosineCentered::class
- CosineWeighted::class
- Jaccard::class
- SlopeOne::class
- Pearson::class (default for user-based)

Available missing values replacement methods:

- MissingValue::ZERO (package default)
- MissingValue::MEAN
- MissingValue::MEDIAN

```
use \Aldeebhasan\LaravelCF\Facades\Recommender;
use \Aldeebhasan\LaravelCF\Enums\RelationType;
use \Aldeebhasan\LaravelCF\Enums\MissingValue;
use \Aldeebhasan\LaravelCF\Similarity;

Recommender::getItemBasedRecommender(RelationType::RATE)
            // use Weighted cosine algorithm and replace the missing values with zero
            ->setSimilarityFunction(CosineWeighted::class,MissingValue::ZERO,true)
             // use SlopeOne algorithm and replace the missing values with the mean
            ->setSimilarityFunction(SlopeOne::class,MissingValue::MEAN,true)

```

Full Example
------------

[](#full-example)

```
use \Aldeebhasan\LaravelCF\Facades\Recommender;
use \Aldeebhasan\LaravelCF\Enums\RelationType;
use \Aldeebhasan\LaravelCF\Enums\MissingValue;
use \Aldeebhasan\LaravelCF\Similarity;

Recommender::addRating(1, 'squid', 1);
Recommender::addRating(2, 'squid', 1);
Recommender::addRating(3, 'squid', 0.2);
Recommender::addRating(1, 'cuttlefish', 0.5);
Recommender::addRating(3, 'cuttlefish', 0.4);
Recommender::addRating(4, 'cuttlefish', 0.9);
Recommender::addRating(1, 'octopus', 0.2);
Recommender::addRating(2, 'octopus', 0.5);
Recommender::addRating(3, 'octopus', 1);
Recommender::addRating(4, 'octopus', 0.4);
Recommender::addRating(1, 'nautilus', 0.2);
Recommender::addRating(3, 'nautilus', 0.4);
Recommender::addRating(4, 'nautilus', 0.5);
$results = Recommender::getItemBasedRecommender(RelationType::RATE)
    ->setSimilarityFunction(CosineWeighted::class, MissingValue::MEAN)
    ->train()
    ->recommendTo('squid');

/**
recommendation results sorted by similarity:
[
  "cuttlefish" => 0.89
  "nautilus" => 0.75
  "octopus" => 0.5
]
**/
```

License
-------

[](#license)

Laravel Recommendation system package is licensed under [The MIT License (MIT)](LICENSE).

Security contact information
----------------------------

[](#security-contact-information)

To report a security vulnerability, contact directly to the developer contact email [Here](mailto:aldeeb.91@gmail.com).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

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

Total

3

Last Release

1036d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/74e7b9d93b0f666f462ad0be43dde05991e9d141f9fe840009775808107d440e?d=identicon)[aldeebhasan](/maintainers/aldeebhasan)

---

Top Contributors

[![aldeebhasan](https://avatars.githubusercontent.com/u/62222392?v=4)](https://github.com/aldeebhasan "aldeebhasan (1 commits)")

---

Tags

laravelstatisticsrecommendationcollaborative filteringproduct recommendationsfast recommendation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aldeebhasan-laravelcf/health.svg)

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

###  Alternatives

[wnx/laravel-stats

Get insights about your Laravel Project

1.8k1.8M7](/packages/wnx-laravel-stats)[phpjuice/slopeone

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

858.7k](/packages/phpjuice-slopeone)[timothepearce/laravel-time-series

Laravel Time Series provides an API to create and maintain projected data from you Eloquent models, and represent them as time-series.

955.4k](/packages/timothepearce-laravel-time-series)[amendozaaguiar/filament-route-statistics

Filament route statictics viewer

3225.0k1](/packages/amendozaaguiar-filament-route-statistics)[cornford/googlitics

An easy way to integrate Google Analytics with Laravel.

3310.2k](/packages/cornford-googlitics)

PHPackages © 2026

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