PHPackages                             loop54/php-connector - 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. loop54/php-connector

ActiveLibrary[API Development](/categories/api)

loop54/php-connector
====================

Wrapper around the API for querying your Loop54 engine.

3.0.5(11mo ago)626.9k↑12.5%2BSD-3-ClausePHPPHP 7.3 - 8.4CI failing

Since Nov 22Pushed 11mo ago8 watchersCompare

[ Source](https://github.com/LoopFiftyFour/PHP-Connector)[ Packagist](https://packagist.org/packages/loop54/php-connector)[ Docs](https://github.com/LoopFiftyFour/PHP-Connector)[ RSS](/packages/loop54-php-connector/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (40)Used By (0)

Loop54 API: PHP Connector
=========================

[](#loop54-api-php-connector)

Loop54 is a learning search engine for e-commerce. This library aims to make it as easy as possible to integrate the service with your PHP site.

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

[](#installation)

We recommend using [Composer](https://getcomposer.org/) to handle your dependencies; if you are, install the Loop54 PHP connector by running

```
$ composer require loop54/php-connector
```

This will install it to the `vendor` subdirectory used by composer for third-party dependencies. Composer also sets up automatic autoloads of all the dependencies it manages, but to tell your PHP about these, you may have to add the following call somewhere early in your application.

```
require_once(__DIR__ . '/vendor/autoload.php');
```

### Using PHAR Archive

[](#using-phar-archive)

There are also standalone phar archives of all releases available for download. They are not automatically kept up to date, so if you need one of these, please contact us.

Usage
-----

[](#usage)

This connector is split into a simple, high-level library, and an advanced, low-level API binding. You find the high-level library in the `lib` directory, and the low-level binding in the `lib/OpenAPI` directory.

For the most common tasks, the high-level library should suffice. This includes things such as

- Making search requests
- Adding facets
- Listing products in a category
- Filtering out e.g. products that are out of stock
- Sorting products based on their price
- Paginating among results
- Getting results related to a search query
- Getting autocomplete suggestions
- Sending user interaction events
- Giving the user spelling suggestions

However, some more advanced functionality is only available using the low-level binding. Examples of this includes:

- Sorting on more than one attribute simultaneously (e.g. primarily on manufacturer, but then within the same manufacturer, on increasing price)
- Customise the order of facets returned by the engine
- Getting the total number of hits for a search query
- Submitting arbitrary data for client-specific purposes
- Showing all products that match complicated criteria

The high-level library is implemented in terms of the low-level one, and is designed to be fully interoperable with it. This means that it is possible (and encouraged!) to use the high-level connector for most operations, and then drop down to the lower level binding only briefly for operations that require it.

### Configuration

[](#configuration)

Most of the interaction you have with the connector starts out from an instance of the `\Loop54\API\Client` class. The most common way to instantiate this for a web application is

```
$remoteClientInfo = new \Loop54\API\RemoteClientInfo\WebClient();
$connector = new \Loop54\API\Client(
    'URL_TO_YOUR_ENDPOINT',
    'YOUR_API_KEY',
    $remoteClientInfo
);
```

In order for the Loop54 engine to properly register user interaction, it needs to be told about things like the IP address and user-agent of the end user. The `\Loop54\API\RemoteClientInfo\WebClient` object will automatically get this information from the PHP environment.

Another important parameter that should be constant per visitor is user ID (`userId`). In your code, you should create a cookie named `Loop54User` with a generated unique userId value. The example how to generate it you could find in `examples/app/templates/base.html.twig`

If you want more control over this, the `\Loop54\API\RemoteClientInfo\Client`interface contains the methods to implement. A sample implementation that simply returns static values is available as `\Loop54\API\RemoteClientInfo\SimpleClient`.

### Implementation Guidance

[](#implementation-guidance)

After you have configured the connector, you are good to go! The next thing to read is the [Loop54 technical documentation and developer guide](https://docs.loop54.com/latest/), which contains general implementation guidance and advice – with code examples for this PHP connector.

### Examples

[](#examples)

Included are two examples of how to use the library.

#### `examples/Simple.php`

[](#examplessimplephp)

A plain console application focused on demonstrating the core features of the connector, and not dealing with things like routes, templates, error handling and other real-world concerns.

#### `examples/app`

[](#examplesapp)

A full-blown Symfony web applications with some features implemented, in order to show what using the connector may look like in a more realistic scenario.

### High-level library

[](#high-level-library)

The best available assistance for dealing with the high-level library is found under *Implementation Guidance* above.

### Low-level Bindings

[](#low-level-bindings)

Since the low-level binding is practically a 1:1 mapping of [the JSON API the engine uses to communicate](https://docs.loop54.com/latest/api/docs.html), familiarity with this API helps in navigating the low-level binding.

The low-level binding is generated from the API specification using the [OpenAPI generator](https://github.com/OpenAPITools/openapi-generator). The classes produced by the generator are extremely regular in their design, so once you have learned to translate the API schema to a generated PHP class, you will be able to work with them all fluently.

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

[](#contributing)

We welcome any and all contributions! None of us are PHP experts, so if you think you've find something that looks wrong – it probably is. Feel free to ​file an issue or submit a pull request.

### Setup

[](#setup)

First make sure you've installed all dependencies, including dev ones:

```
$ composer install

```

### Running the Symphony app

[](#running-the-symphony-app)

The library has a test application using the Symphony web framework. This can be used to verify and test functionality while developing. The app can be run on a local webserver on port 5001 by

```
$ cd examples/app
$ php -S localhost:5001

```

Choose whatever port you like. Then open localhost:5001 (or whatever you chose) in a web browser and you can try out the app. It's very simple, but supports search, autoComplete and createEvents.

### Running the examples

[](#running-the-examples)

The code under /examples are runnable and act as one part of testing the library. They can be run using

```
$ php examples/Simple.php

```

These are set up to perform a set of requests to  and should not throw any exceptions.

### Testing

[](#testing)

Unit and integration tests can be run by

```
./vendor/bin/phpunit test

```

To test multiple PHP versions (using docker) run

```
./test-matrix.sh

```

This will run the (examples)(### Running the examples) in addition to the unit and integration tests.

### Generating Low-level Library

[](#generating-low-level-library)

Code under `lib/OpenAPI` is generated from [the OpenAPI specification](https://docs.loop54.com/latest/api/docs.html) with a semi-manual process. First, download the schema from . Then, we generate the code from the specification and write it to a temporary location.

```
openapi-generator-cli generate \
    -g php -i schema.json -o ~/tmp/phpgen -t templates \
    --invoker-package 'Loop54\API\OpenAPI'

```

If you don't have openapi-generator-cli you can get it with

```
npm install @openapitools/openapi-generator-cli -g

```

**If you are having problem with the command above generating names without back-slashes (eg 'Loop54APIOpenAPI'). Try double escaping the command: `--invoker-package 'Loop54\\API\\OpenAPI'` (or even `\\\\`)**

this generates also a bunch of supporting code that we're not very interested in, so we copy over just the interesting bits to the repository. (Note that the periods are required here, in order for rsync to correctly guess our intent.)

```
rsync -a ~/tmp/phpgen/lib/. lib/OpenAPI/.

```

### Building phar Archive

[](#building-phar-archive)

Using [phar-composer](https://github.com/clue/phar-composer):

1. First, ensure development requirements are cleaned out, and only runtime dependencies are installed. Without this step, the archive would include e.g. the example Symfony app, which just occupies a bunch of space for no good reason.

    ```
    $ composer install --no-dev
    ```
2. Then create a phar archive from the connector source and all installed dependencies.

    ```
    $ php -d phar.readonly=off phar-composer.phar build .
    Loop54PHPConnector-1.0.0.phar
    ```

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance51

Moderate activity, may be stable

Popularity33

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity91

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~133 days

Total

26

Last Release

347d ago

Major Versions

1.3.2 → 2.0.12021-12-21

2.2.5 → 3.0.12024-02-27

PHP version history (5 changes)1.0.0PHP &gt;=5.6

1.1.0PHP &gt;=7.4

1.1.2PHP ^7.0

2.0.1PHP 7.3 - 8

3.0.5PHP 7.3 - 8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/63ae4e85f945bf0b3dde3d0e01a1e010d40277ec30aacaa07d76729a4739f236?d=identicon)[Loop54](/maintainers/Loop54)

---

Top Contributors

[![loop54-christoffer](https://avatars.githubusercontent.com/u/72192621?v=4)](https://github.com/loop54-christoffer "loop54-christoffer (12 commits)")[![lukethenuke](https://avatars.githubusercontent.com/u/3072358?v=4)](https://github.com/lukethenuke "lukethenuke (11 commits)")[![Rayn93](https://avatars.githubusercontent.com/u/12749730?v=4)](https://github.com/Rayn93 "Rayn93 (9 commits)")[![oleg-loop54](https://avatars.githubusercontent.com/u/75134724?v=4)](https://github.com/oleg-loop54 "oleg-loop54 (2 commits)")[![joelwkall](https://avatars.githubusercontent.com/u/10114942?v=4)](https://github.com/joelwkall "joelwkall (1 commits)")[![alexandrosk](https://avatars.githubusercontent.com/u/7273866?v=4)](https://github.com/alexandrosk "alexandrosk (1 commits)")[![vasyltkachenko](https://avatars.githubusercontent.com/u/121886324?v=4)](https://github.com/vasyltkachenko "vasyltkachenko (1 commits)")

---

Tags

apisearchserviceecommerce

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/loop54-php-connector/health.svg)

```
[![Health](https://phpackages.com/badges/loop54-php-connector/health.svg)](https://phpackages.com/packages/loop54-php-connector)
```

###  Alternatives

[aimeos/aimeos-headless

Aimeos headless ecommerce system

2.5k2.3k](/packages/aimeos-aimeos-headless)[aerni/laravel-spotify

A Laravel wrapper for the Spotify Web API

209145.6k](/packages/aerni-laravel-spotify)[robwittman/shopify-php-sdk

PHP SDK for Shopify API

7098.9k1](/packages/robwittman-shopify-php-sdk)[siro/php-klaviyo-api

Low level but elegant Klaviyo full API wrapper for PHP with asynchronous track event support

16115.4k](/packages/siro-php-klaviyo-api)

PHPackages © 2026

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