PHPackages                             homedoctor-es/laravel-mirakl - 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. [API Development](/categories/api)
4. /
5. homedoctor-es/laravel-mirakl

ActiveLibrary[API Development](/categories/api)

homedoctor-es/laravel-mirakl
============================

Laravel integration for the Mirakl PHP SDK including shop client wrapper

0.2(7mo ago)0156MITPHPPHP ^8.1|^8.2|^8.3

Since Nov 18Pushed 7mo agoCompare

[ Source](https://github.com/homedoctor-es/laravel-mirakl)[ Packagist](https://packagist.org/packages/homedoctor-es/laravel-mirakl)[ RSS](/packages/homedoctor-es-laravel-mirakl/feed)WikiDiscussions main Synced 3w ago

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

Laravel Mirakl
==============

[](#laravel-mirakl)

Laravel integration for the [Mirakl PHP SDK](https://github.com/mirakl/sdk-php-shop) including a shop client wrapper.

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

With Composer installed, you can then install the extension using the following commands:

```
$ php composer.phar require homedoctor-es/laravel-mirakl
```

or add

```
"require": {
    "homedoctor-es/laravel-mirakl": "*"
}
```

to the require section of your `composer.json` file.

Configuration
-------------

[](#configuration)

### 1. Register the ServiceProvider (Laravel &lt; 11)

[](#1-register-the-serviceprovider-laravel--11)

> **Note:** For Laravel 11+, the service provider is auto-discovered.

Register the ServiceProvider in your `config/app.php` service provider list:

```
// config/app.php
return [
    //other stuff
    'providers' => [
        //other stuff
        \HomedoctorEs\Laravel\Mirakl\MiraklServiceProvider::class,
    ];
];
```

### 2. Add the Facade (Optional)

[](#2-add-the-facade-optional)

If you want, you can add the following facade to the `$aliases` section:

```
// config/app.php
return [
    //other stuff
    'aliases' => [
        //other stuff
        'Mirakl' => \HomedoctorEs\Laravel\Mirakl\Facades\Mirakl::class,
    ];
];
```

### 3. Publish the Configuration

[](#3-publish-the-configuration)

Publish the package configuration file:

```
$ php artisan vendor:publish --provider='HomedoctorEs\Laravel\Mirakl\MiraklServiceProvider'
```

### 4. Set Environment Variables

[](#4-set-environment-variables)

Set the API credentials in your `.env` file:

```
MIRAKL_API_URL=https://your-instance.mirakl.net/api
MIRAKL_API_KEY=your_api_key_here
MIRAKL_SHOP_ID=your_shop_id_here
MIRAKL_TIMEOUT=30
```

Or you can set them directly in the `config/mirakl.php` file:

```
// config/mirakl.php
return [
    'api_url' => 'https://your-instance.mirakl.net/api',
    'api_key' => 'your_api_key_here',
    'shop_id' => 'your_shop_id_here',
    'timeout' => 30,
];
```

Usage
-----

[](#usage)

You can use the facade alias `Mirakl` to execute API calls. The authentication params will be automatically injected.

### Using the Facade

[](#using-the-facade)

```
use HomedoctorEs\Laravel\Mirakl\Facades\Mirakl;
use Mirakl\MMP\Shop\Request\Offer\GetOfferRequest;
use Mirakl\MMP\Shop\Request\Offer\GetOffersRequest;

// Get a single offer
$request = new GetOfferRequest('OFFER_ID');
$offer = Mirakl::getOffer($request);

// Get all offers with pagination
$request = new GetOffersRequest();
$request->setMax(100); // Max 100 per page
$request->setOffset(0);
$offers = Mirakl::getOffers($request);

// You can also get raw response
$rawResponse = Mirakl::run($request);
// or
$rawResponse = Mirakl::raw()->getOffer($request);
```

### Using Dependency Injection

[](#using-dependency-injection)

```
use Mirakl\MMP\Shop\Client\ShopApiClient;
use Mirakl\MMP\Shop\Request\Product\GetProductsRequest;

class ProductController extends Controller
{
    protected $mirakl;

    public function __construct(ShopApiClient $mirakl)
    {
        $this->mirakl = $mirakl;
    }

    public function index()
    {
        $request = new GetProductsRequest();
        $products = $this->mirakl->getProducts($request);

        return response()->json($products);
    }
}
```

### Working with Orders

[](#working-with-orders)

```
use HomedoctorEs\Laravel\Mirakl\Facades\Mirakl;
use Mirakl\MMP\Shop\Request\Order\GetOrdersRequest;

$request = new GetOrdersRequest();
$request->setMax(50);
$request->setOffset(0);

// You can also filter by date
$request->setStartDate(new \DateTime('-30 days'));
$request->setEndDate(new \DateTime());

$orders = Mirakl::getOrders($request);

foreach ($orders as $order) {
    echo $order->getId() . ' - ' . $order->getStatus() . PHP_EOL;
}
```

### Pagination Example

[](#pagination-example)

```
use HomedoctorEs\Laravel\Mirakl\Facades\Mirakl;
use Mirakl\MMP\Shop\Request\Offer\GetOffersRequest;

function getAllOffers()
{
    $allOffers = [];
    $offset = 0;
    $max = 100;

    do {
        $request = new GetOffersRequest();
        $request->setMax($max);
        $request->setOffset($offset);

        $result = Mirakl::run($request);
        $data = json_decode($result->getBody()->getContents(), true);

        $offers = $data['offers'] ?? [];
        $totalCount = $data['total_count'] ?? 0;

        $allOffers = array_merge($allOffers, $offers);
        $offset += $max;

    } while (count($allOffers) < $totalCount);

    return $allOffers;
}
```

### Error Handling

[](#error-handling)

```
use HomedoctorEs\Laravel\Mirakl\Facades\Mirakl;
use Mirakl\MMP\Shop\Request\Offer\GetOfferRequest;
use GuzzleHttp\Exception\ClientException;

try {
    $request = new GetOfferRequest('INVALID_OFFER_ID');
    $offer = Mirakl::getOffer($request);
} catch (ClientException $e) {
    // Handle API errors (404, 400, etc.)
    $statusCode = $e->getResponse()->getStatusCode();
    $errorBody = $e->getResponse()->getBody()->getContents();

    Log::error('Mirakl API Error', [
        'status_code' => $statusCode,
        'error' => $errorBody
    ]);
} catch (\Exception $e) {
    // Handle other errors
    Log::error('Unexpected error', ['error' => $e->getMessage()]);
}
```

### Rate Limiting

[](#rate-limiting)

Mirakl API has rate limits. If you receive an HTTP 429 "Too Many Requests" error, you should wait before making a new request. The response will contain a `Retry-After` header:

```
use GuzzleHttp\Exception\ClientException;

try {
    $result = Mirakl::getOffers($request);
} catch (ClientException $e) {
    if ($e->getResponse()->getStatusCode() === 429) {
        $retryAfter = $e->getResponse()->getHeader('Retry-After')[0] ?? 60;
        sleep((int) $retryAfter);
        // Retry the request
    }
}
```

Integration with Porto Pattern
------------------------------

[](#integration-with-porto-pattern)

If you're using this package in a Porto-based architecture (like Apiato), here's how you might structure it:

### Task Example

[](#task-example)

```
namespace App\Containers\Mirakl\Tasks;

use App\Ship\Parents\Tasks\Task;
use HomedoctorEs\Laravel\Mirakl\Facades\Mirakl;
use Mirakl\MMP\Shop\Request\Offer\GetOffersRequest;

class GetOffersTask extends Task
{
    public function run(int $max = 100, int $offset = 0)
    {
        $request = new GetOffersRequest();
        $request->setMax($max);
        $request->setOffset($offset);

        return Mirakl::getOffers($request);
    }
}
```

### Action Example

[](#action-example)

```
namespace App\Containers\Mirakl\Actions;

use App\Containers\Mirakl\Tasks\GetOffersTask;
use App\Ship\Parents\Actions\Action;

class SyncOffersAction extends Action
{
    public function __construct(
        private GetOffersTask $getOffersTask
    ) {}

    public function run()
    {
        $allOffers = [];
        $offset = 0;
        $max = 100;

        do {
            $offers = $this->getOffersTask->run($max, $offset);

            // Process offers...
            foreach ($offers as $offer) {
                // Store in database, etc.
            }

            $offset += $max;

        } while (count($offers) === $max);

        return $allOffers;
    }
}
```

Available Request Types
-----------------------

[](#available-request-types)

The Mirakl SDK provides numerous request types. Here are some commonly used ones:

### Offers

[](#offers)

- `GetOfferRequest` - Get a single offer
- `GetOffersRequest` - Get all offers
- `CreateOfferRequest` - Create new offers
- `UpdateOfferRequest` - Update existing offers

### Products

[](#products)

- `GetProductsRequest` - Get products
- `ImportProductsRequest` - Import products
- `SynchronizeProductsRequest` - Synchronize products

### Orders

[](#orders)

- `GetOrdersRequest` - Get orders
- `AcceptOrderRequest` - Accept an order
- `RefundOrderRequest` - Refund an order

### Shipping

[](#shipping)

- `GetShippingRatesRequest` - Get shipping rates
- `UpdateShippingRequest` - Update shipping information

For a complete list of available requests, please refer to the [Mirakl SDK documentation](https://github.com/mirakl/sdk-php-shop).

Testing
-------

[](#testing)

```
$ composer test
```

License
-------

[](#license)

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

Credits
-------

[](#credits)

- [Homedoctor](https://github.com/homedoctor-es)
- [All Contributors](https://github.com/homedoctor-es/laravel-mirakl/contributors)

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance65

Regular maintenance activity

Popularity14

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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

Total

2

Last Release

214d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13337359?v=4)[Homedoctor](/maintainers/Homedoctor)[@HomeDoctor](https://github.com/HomeDoctor)

---

Tags

apilaravelshopmarketplacemirakl

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/homedoctor-es-laravel-mirakl/health.svg)

```
[![Health](https://phpackages.com/badges/homedoctor-es-laravel-mirakl/health.svg)](https://phpackages.com/packages/homedoctor-es-laravel-mirakl)
```

###  Alternatives

[aimeos/aimeos-laravel

Cloud native, API first Laravel eCommerce package with integrated AI for ultra-fast online shops, marketplaces and complex B2B projects

8.6k220.7k5](/packages/aimeos-aimeos-laravel)[essa/api-tool-kit

set of tools to build an api with laravel

53386.5k](/packages/essa-api-tool-kit)[smodav/mpesa

M-Pesa API implementation

16167.1k1](/packages/smodav-mpesa)

PHPackages © 2026

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