PHPackages                             ravols/laravel-recocube - 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. ravols/laravel-recocube

ActiveLibrary

ravols/laravel-recocube
=======================

Package for implementation of Recocube to Laravel PHP

01PHPCI passing

Since Jan 3Pushed 4mo agoCompare

[ Source](https://github.com/ravols/laravel-recocube)[ Packagist](https://packagist.org/packages/ravols/laravel-recocube)[ RSS](/packages/ravols-laravel-recocube/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Recocube
================

[](#laravel-recocube)

[![Latest Version on Packagist](https://camo.githubusercontent.com/20f0ee0a3e3779fd8110937f62d01565042e6e616f0920347a2a0f73d7ee317a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7261766f6c732f6c61726176656c2d7265636f637562652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ravols/laravel-recocube)[![GitHub Tests Action Status](https://camo.githubusercontent.com/c024cbae20e2b54ea1f6aee4b4d6e270bdf69d15299e76d5514d7d3eb7a072ec/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7261766f6c732f6c61726176656c2d7265636f637562652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/ravols/laravel-recocube/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/d28d5b25a315ea997b2235165aee49484193d8f12369f543871d9ac463b9e0d8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7261766f6c732f6c61726176656c2d7265636f637562652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/ravols/laravel-recocube/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/f6d4f008c49c27c4255b83ee836b703c0f91a4d4bb810f1d44bd8ec67d6d6d00/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7261766f6c732f6c61726176656c2d7265636f637562652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ravols/laravel-recocube)

A Laravel package for seamless integration with Recocube's recommendation engine API. This package provides an elegant way to fetch personalized product recommendations based on shopping cart contents, individual products, categories, and user behavior.

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Laravel 10.0 or higher

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

[](#installation)

You can install the package via composer:

```
composer require ravols/laravel-recocube
```

Publish the config file with:

```
php artisan vendor:publish --tag="laravel-recocube-config"
```

This is the contents of the published config file:

```
return [
    'api_key' => env('RECOCUBE_API_KEY', ''),
    'api_retail_client_id' => env('RECOCUBE_API_RETAIL_CLIENT_ID', ''),
    'api_url' => env('RECOCUBE_API_URL', 'https://recocube.test/api'),
    'api_version' => env('RECOCUBE_API_VERSION', 'v1'),
];
```

Add your Recocube credentials to your `.env` file:

```
RECOCUBE_API_KEY=your-api-key
RECOCUBE_API_RETAIL_CLIENT_ID=your-retail-client-id
RECOCUBE_API_URL=https://api.recocube.com/api
RECOCUBE_API_VERSION=v1
```

Usage
-----

[](#usage)

### Fetching Recommendations by Cart

[](#fetching-recommendations-by-cart)

Get product recommendations based on the current shopping cart contents:

```
use Ravols\LaravelRecocube\Facades\LaravelRecocube;
use Ravols\LaravelRecocube\Data\RecoCartItem;
use Ravols\LaravelRecocube\Data\RecoCartItemsCollection;

// Create cart items
$cartItems = new RecoCartItemsCollection([
    new RecoCartItem(product_id: 123, quantity: 2),
    new RecoCartItem(product_id: 456, quantity: 1),
]);

// Or add items one by one
$cartItems = new RecoCartItemsCollection();
$cartItems->addItem(new RecoCartItem(product_id: 123, quantity: 2));
$cartItems->addItem(new RecoCartItem(product_id: 456, quantity: 1));

// Fetch recommendations
$recommendations = LaravelRecocube::fetchRecoByCart($cartItems);
```

### Fetching Recommendations by Product

[](#fetching-recommendations-by-product)

Get recommendations based on a single product (coming soon):

```
use Ravols\LaravelRecocube\Facades\LaravelRecocube;

$productId = 123;
$recommendations = LaravelRecocube::fetchRecoByProduct($productId);
```

### Fetching Recommendations by Category

[](#fetching-recommendations-by-category)

Get recommendations for a specific product category (coming soon):

```
use Ravols\LaravelRecocube\Facades\LaravelRecocube;

$categoryId = 10;
$recommendations = LaravelRecocube::fetchRecoByCategory($categoryId);
```

### Fetching Recommendations by User

[](#fetching-recommendations-by-user)

Get personalized recommendations for a specific user (coming soon):

```
use Ravols\LaravelRecocube\Facades\LaravelRecocube;

$userId = 42;
$recommendations = LaravelRecocube::fetchRecoByUser($userId);
```

### Working with RecoCartItemsCollection

[](#working-with-recocartitemscollection)

The `RecoCartItemsCollection` is a type-safe collection that only accepts `RecoCartItem` instances:

```
use Ravols\LaravelRecocube\Data\RecoCartItem;
use Ravols\LaravelRecocube\Data\RecoCartItemsCollection;

// Create an empty collection
$cartItems = new RecoCartItemsCollection();

// Add items using addItem()
$cartItems->addItem(new RecoCartItem(product_id: 100, quantity: 1));

// Add items using push()
$cartItems->push(new RecoCartItem(product_id: 200, quantity: 3));

// Add items using put()
$cartItems->put('key', new RecoCartItem(product_id: 300, quantity: 2));

// All standard Laravel Collection methods are available
$count = $cartItems->count();
$filtered = $cartItems->filter(fn($item) => $item->quantity > 1);
```

### Example in a Controller

[](#example-in-a-controller)

```
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Ravols\LaravelRecocube\Facades\LaravelRecocube;
use Ravols\LaravelRecocube\Data\RecoCartItem;
use Ravols\LaravelRecocube\Data\RecoCartItemsCollection;

class RecommendationController extends Controller
{
    public function getCartRecommendations(Request $request)
    {
        $cart = $request->user()->cart;

        // Build cart items collection from your cart
        $cartItems = new RecoCartItemsCollection();
        foreach ($cart->items as $item) {
            $cartItems->addItem(
                new RecoCartItem(
                    product_id: $item->product_id,
                    quantity: $item->quantity
                )
            );
        }

        // Get recommendations
        $recommendations = LaravelRecocube::fetchRecoByCart($cartItems);

        return view('recommendations', [
            'recommendations' => $recommendations
        ]);
    }
}
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Ravols](https://github.com/ravols)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance52

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

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.

### Community

Maintainers

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

---

Top Contributors

[![rudolfbruder](https://avatars.githubusercontent.com/u/56951790?v=4)](https://github.com/rudolfbruder "rudolfbruder (6 commits)")

### Embed Badge

![Health badge](/badges/ravols-laravel-recocube/health.svg)

```
[![Health](https://phpackages.com/badges/ravols-laravel-recocube/health.svg)](https://phpackages.com/packages/ravols-laravel-recocube)
```

PHPackages © 2026

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