PHPackages                             answear/luigis-box-bundle - 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. answear/luigis-box-bundle

ActiveSymfony-bundle

answear/luigis-box-bundle
=========================

Luigi's Box integration for Symfony.

5.3.0(4mo ago)633.6k↓41.7%2MITPHPPHP ^8.4

Since May 8Pushed 4mo ago4 watchersCompare

[ Source](https://github.com/answear/luigis-box-bundle)[ Packagist](https://packagist.org/packages/answear/luigis-box-bundle)[ RSS](/packages/answear-luigis-box-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (18)Versions (30)Used By (0)

Luigi's Box Bundle
==================

[](#luigis-box-bundle)

[Luigi's Box](https://www.luigisbox.com/) integration for Symfony. Luigi's Box documentation can be found here: .

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

[](#installation)

- install with Composer

```
composer require answear/luigis-box-bundle
```

Setup
-----

[](#setup)

- provide required config data: `publicKey` and `privateKey`
- `searchCacheTtl` is time to live for Luigi cache request in seconds (max 300 seconds - this is Luigi's Box limit)

```
# config/packages/answear_luigis_box.yaml
answear_luigis_box:
    default_config: second_config_name
    configs:
        your_config_name:
            host: 'https://live.luigisbox.com' #default
            publicKey: 'your_public_key'
            privateKey: 'your_private_key'
            connectionTimeout: 4.0 #default
            requestTimeout: 10.0 #default
            searchTimeout: 6.0 #default
            searchCacheTtl: 0 #default
        second_config_name:
            publicKey: 'your_public_key'
            privateKey: 'your_private_key'
```

If you have only one config you can omit `default_config` node. Configs will be passed to `\Answear\LuigisBoxBundle\Service\ConfigProvider` class.

If you have more configurations you can change them as follows

```
use Answear\LuigisBoxBundle\Service\ConfigProvider;

/** @var ConfigProvider $configProvider **/
$configProvider->setConfig('your_config_name');
```

and use application as before.

If you need to pass custom headers to search request do it as follows

```
use Answear\LuigisBoxBundle\Service\ConfigProvider;

/** @var ConfigProvider $configProvider **/
$configProvider->setHeader('header-name', 'header-value');

/* reset all headers */
$configProvider->resetHeaders();
```

### Dynamic configurations

[](#dynamic-configurations)

You can pass additional configuration.

```
use Answear\LuigisBoxBundle\DTO\ConfigDTO;
use Answear\LuigisBoxBundle\Service\ConfigProvider;

/** @var ConfigProvider $configProvider **/
$configProvider->addConfig('your_config_name', new ConfigDTO(...));
```

Usage
-----

[](#usage)

### Content requests

[](#content-requests)

1. Full [content update](https://live.luigisbox.com/?php#content-updates-content-update) document

```
use Answear\LuigisBoxBundle\ValueObject\ContentUpdate;
use Answear\LuigisBoxBundle\ValueObject\ContentUpdateCollection;

// ...

$collection = new ContentUpdateCollection([new ContentUpdate('product title', 'product/url', 'object type', ['field' => 'field 1'])]);

/** @var \Answear\LuigisBoxBundle\Service\RequestInterface $request **/
$apiResponse = $request->contentUpdate($collection);
```

First argument (`$title`) will be used as product's title in Luigi's Box unless a `title` field is present in the `$fields` argument.

1. [Partial update](https://live.luigisbox.com/?php#content-updates-partial-content-update)

```
use Answear\LuigisBoxBundle\ValueObject\ContentUpdateCollection;
use Answear\LuigisBoxBundle\ValueObject\PartialContentUpdate;

// ...

$collection = new ContentUpdateCollection([new PartialContentUpdate('product/url', 'object type', ['title' => 'product title'])]);

/** @var \Answear\LuigisBoxBundle\Service\RequestInterface $request **/
$apiResponse = $request->partialContentUpdate($collection);
```

1. [Content removal](https://live.luigisbox.com/?php#content-updates-content-removal)

```
use Answear\LuigisBoxBundle\ValueObject\ContentRemoval;
use Answear\LuigisBoxBundle\ValueObject\ContentRemovalCollection;

// ...

$collection = new ContentRemovalCollection([new ContentRemoval('product/url', 'product')]);

/** @var \Answear\LuigisBoxBundle\Service\RequestInterface $request **/
$apiResponse = $request->contentRemoval($collection);
```

1. Change availability

Additional method to simply enable/disable objects - partial update will be used.

```
use Answear\LuigisBoxBundle\ValueObject\ContentAvailability;
use Answear\LuigisBoxBundle\ValueObject\ContentAvailabilityCollection;

// ...

$isAvailable = true;
$collection = new ContentAvailabilityCollection([new ContentAvailability('product/url', $isAvailable)]);

/** @var \Answear\LuigisBoxBundle\Service\RequestInterface $request **/
$apiResponse = $request->changeAvailability($collection);

// ... or pass one object

$isAvailable = true;
/** @var \Answear\LuigisBoxBundle\Service\RequestInterface $request **/
$apiResponse = $request->changeAvailability(new ContentAvailability('product/url', $isAvailable));
```

---

In all request you can catch some exceptions:

- `BadRequestException` - bad request,
- `TooManyItemsException` - make request with fewer items,
- `MalformedResponseException` - something went wrong with Luigi's Box api response,
- `TooManyRequestsException` - delay request rate,
- `ServiceUnavailableException`

Consider catching them separately:

```
use Answear\LuigisBoxBundle\Exception\BadRequestException;
use Answear\LuigisBoxBundle\Exception\TooManyItemsException;
use Answear\LuigisBoxBundle\Exception\MalformedResponseException;
use Answear\LuigisBoxBundle\Exception\TooManyRequestsException;
use Answear\LuigisBoxBundle\Exception\ServiceUnavailableException;

try {
    // ... request
} catch (BadRequestException $exception){
    //bad request
    $request = $exception->request;
    $response = $exception->response;
} catch (TooManyItemsException $exception){
    //items limit reached
    $limit = $exception->limit;
} catch (MalformedResponseException $exception){
    //bad response
    $response = $exception->response;
} catch (TooManyRequestsException $exception){
    //repeat request after $retryAfter seconds
    $retryAfter = $exception->retryAfterSeconds;
} catch (ServiceUnavailableException $exception){
    //delay request
}
```

### Content response

[](#content-response)

`\Answear\LuigisBoxBundle\Response\ApiResponse`:

- (bool) `$success` - `true` if all documents will be passed successfully,
- (int) `$okCount` - number of successfully passed documents,
- (int) `$errorsCount` - number of failed documents,
- (array) `$errors` - array of `\Answear\LuigisBoxBundle\Response\ApiResponseError` objects,
- (array) `$rawResponse` - decoded response from api.

`ApiResponseError`:

- (string) `$url` - url of document
- (string) `$type` - type of error (ex. `malformed_input`)
- (string) `$reason` - failure text (ex. `incorrect object format`)
- (array|null) `$causedBy` - specific reason of error (ex. `["url": ["is missing"]]`)

Note!

`ApiResponse::$success` will be set to `false` if any of passed documents fails. Check `$okCount` if you want to know how many documents were updated and `$errors` to check exactly which documents failed.

### Searching (documentation [here](https://live.luigisbox.com/#search-as-a-service))

[](#searching-documentation-here)

1. Request

```
use Answear\LuigisBoxBundle\ValueObject\SearchUrlBuilder;

// ...

$page = 3;
$urlBuilder = new SearchUrlBuilder($page);
$urlBuilder
    ->setQuery('nice top')
    ->addFilter('type', 'product')
    ->addFilter('category', 'top')
    ->addFilter('brand', 'Medicine')
    ->addFilter('brand', 'Answear')
    ->addPrefer('brand', 'Answear')
    ->setSort('size', 'asc');

//the above code produces a url query like `size=10&page=3&q=nice+top&f%5B0%5D=type%3Aproduct&f%5B1%5D=category%3Atop&f%5B2%5D=brand%3AMedicine&f%5B3%5D=brand%3AAnswear&sort=size%3Aasc&prefer%5B0%5D=brand%3AAnswear`

/** @var \Answear\LuigisBoxBundle\Service\SearchRequestInterface $request **/
$searchResponse = $request->search($urlBuilder);
```

Check the Luigi's Box documentation to find out exact purpose of each field `SearchUrlBuilder` is exposing.

1. Response

`SearchRequest::search()` will return a `SearchResponse` object with following fields:

- (string) $searchUrl
- (string) $query
- (string|null) $correctedQuery
- (array) $filters
- (Hit\[\]) $hits. `Hit`:
    - (string) $url;
    - (array) $attributes;
    - (array) $nested;
    - (string) $type;
    - (array) $highlight;
    - (bool) $exact;
    - (bool) $alternative;
- (Hit\[\]) $quickSearchHits
    - like above
- (Facet\[\]) $facets. `Facet`:
    - (string) $name;
    - (string) $type;
    - (array) $values;
- (int) $totalHits
- (int) $currentSize

### Update by query (documentation [here](https://live.luigisbox.com/#content-updates-update-by-query))

[](#update-by-query-documentation-here)

1. Update

```
use Answear\LuigisBoxBundle\ValueObject\UpdateByQuery;

// ...
$types = ['product'];
$fields = ['color' => 'green'];
$search = new UpdateByQuery\Search($types, $fields);

$updateFields = ['color' => ['olive', 'emerald']];
$update = new UpdateByQuery\Update($updateFields);

$updateByQuery = new UpdateByQuery($search, $update);

/** @var \Answear\LuigisBoxBundle\Service\UpdateByQueryRequest $request **/
$response = $request->update($updateByQuery);

$jobId = $response->getJobId();
```

1. Retrieve job status

```
use Answear\LuigisBoxBundle\ValueObject\UpdateByQuery;

$jobId = 1;

/** @var \Answear\LuigisBoxBundle\Service\UpdateByQueryRequest $request **/
$response = $request->getStatus($jobId);
```

`getStatus` will return `UpdateByQueryStatusResponse` with following fields:

- (array) $rawResponse
- (string) $trackerId
- (bool) $completed
- (int|null) $okCount - null if not completed
- (int|null) $errorsCount - null if not completed
- (ApiResponseError\[\]|null) $errors - null if not completed

Final notes
-----------

[](#final-notes)

Feel free to make pull requests with new features, improvements or bug fixes. The Answear team will be grateful for any comments.

**Have fun!**

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance77

Regular maintenance activity

Popularity34

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 75% 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 ~79 days

Recently: every ~62 days

Total

27

Last Release

125d ago

Major Versions

v1.4.0 → v2.0.02021-02-16

v2.5.0 → 3.0.02022-08-18

3.1.0 → 4.0.02024-10-03

4.2.0 → 5.0.02025-06-02

PHP version history (4 changes)v1.0.0PHP &gt;=7.3

3.0.0PHP &gt;=7.4|^8.0

4.0.0PHP ^8.2

5.0.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/09395def7b7f6c5cfa2cd4b2a115036b9b0c007c16edc114071ddab8b2505f34?d=identicon)[malarzm](/maintainers/malarzm)

![](https://www.gravatar.com/avatar/499384a9b1608d172d356bbbd2121bd221c2feb29132a0a1371f959f612fc00c?d=identicon)[lukasz-falda](/maintainers/lukasz-falda)

---

Top Contributors

[![lukasz-falda](https://avatars.githubusercontent.com/u/55883656?v=4)](https://github.com/lukasz-falda "lukasz-falda (87 commits)")[![Wiktor6](https://avatars.githubusercontent.com/u/24683748?v=4)](https://github.com/Wiktor6 "Wiktor6 (5 commits)")[![olekans](https://avatars.githubusercontent.com/u/135211410?v=4)](https://github.com/olekans "olekans (4 commits)")[![mglowala](https://avatars.githubusercontent.com/u/12442828?v=4)](https://github.com/mglowala "mglowala (3 commits)")[![konradkozaczenko](https://avatars.githubusercontent.com/u/57705320?v=4)](https://github.com/konradkozaczenko "konradkozaczenko (3 commits)")[![SzymonKaminski](https://avatars.githubusercontent.com/u/8536735?v=4)](https://github.com/SzymonKaminski "SzymonKaminski (3 commits)")[![malarzm](https://avatars.githubusercontent.com/u/4947711?v=4)](https://github.com/malarzm "malarzm (3 commits)")[![yekovalenkoa](https://avatars.githubusercontent.com/u/152966920?v=4)](https://github.com/yekovalenkoa "yekovalenkoa (2 commits)")[![bmulawa](https://avatars.githubusercontent.com/u/61696017?v=4)](https://github.com/bmulawa "bmulawa (2 commits)")[![cuchac](https://avatars.githubusercontent.com/u/165461?v=4)](https://github.com/cuchac "cuchac (2 commits)")[![ropczan](https://avatars.githubusercontent.com/u/24248440?v=4)](https://github.com/ropczan "ropczan (1 commits)")[![Ace-COM](https://avatars.githubusercontent.com/u/12625630?v=4)](https://github.com/Ace-COM "Ace-COM (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/answear-luigis-box-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/answear-luigis-box-bundle/health.svg)](https://phpackages.com/packages/answear-luigis-box-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19562.3M1.3k](/packages/drupal-core)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)

PHPackages © 2026

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