PHPackages                             bluerocktel/glpi-php-api-client - 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. bluerocktel/glpi-php-api-client

ActiveLibrary[API Development](/categories/api)

bluerocktel/glpi-php-api-client
===============================

PHP Client for the GLPI API

v1.0.3(1y ago)1182↓100%MITPHPPHP &gt;=8.1

Since Dec 27Pushed 1y ago2 watchersCompare

[ Source](https://github.com/bluerocktel/glpi-php-api-client)[ Packagist](https://packagist.org/packages/bluerocktel/glpi-php-api-client)[ RSS](/packages/bluerocktel-glpi-php-api-client/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (5)Used By (0)

php-sdk
=======

[](#php-sdk)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Latest Version on Packagist](https://camo.githubusercontent.com/254defda6f0e6d27701dcaae629fe2105b5ab8e7c2dd7146cb0b7ac4eb5c8a34/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626c7565726f636b74656c2f676c70692d7068702d6170692d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bluerocktel/glpi-php-api-client)[![Total Downloads](https://camo.githubusercontent.com/116430a857043a681068c1539a115d801f30e05ab2f36d91edd621a6452c3a30/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626c7565726f636b74656c2f676c70692d7068702d6170692d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bluerocktel/glpi-php-api-client)

This package is a light PHP Wrapper / SDK for the [GLPI Project](https://glpi-project.org/fr/) API.

- [Installation](#installation)
- [Authentication](#authentication)
- [Usage](#usage)
    - [Requests](#usage-requests)
    - [Resources](#usage-resources)
    - [Responses](#usage-responses)
    - [Entities](#usage-entities)
    - [Extending the Client](#usage-extends)

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

[](#installation)

This library requires PHP `>=8.1`.

You can install the package via composer:

```
composer require bluerocktel/glpi-php-api-client

```

Authentication
--------------

[](#authentication)

### User token

[](#user-token)

To get started, first generate an App token and a User token from your GLPI dashboard. Then, you can initiate the `GlpiConnector` class providing your instance URL, App token and User token :

```
$api = new BlueRockTEL\Glpi\GlpiConnector(
    apiUrl: 'https://glpi.mycompany.com/apirest.php',
    appToken: 'KSt7zEY3QMZDXZ5Gfyy7uxV4JoolzupiRCS4GPQQ',
    userToken:'muaYfo14YsK9fK2wutKPyZZW9z5JXW7edc5caRt5',
);
```

> If the connector fails to retreive a Session token from the provided credentials, a `BlueRockTEL\Glpi\Exceptions\AuthenticationException` will be thrown.

You can now start using the API :

```
$response = $api->user()->search(); // list users

var_dump(
  $response->failed(), // true if the request returned 4xx or 5xx code.
  $response->json(),   // json response as an array
);
```

Usage
-----

[](#usage)

To query the API, you can either call each API [Endpoints requests](https://github.com/bluerocktel/glpi-php-api-client/tree/main/src/Endpoints) individually, or make use of provided [Resources classes](https://github.com/bluerocktel/glpi-php-api-client/tree/main/src/Resources) which groups the requests into clusters.

### Using Requests

[](#using-requests)

Using single requests is pretty straightforward. You can use the `call()` method of the `GlpiConnector` class to send the desired request to the instance :

```
use BlueRockTEL\Glpi\Endpoints;

$api = new BlueRockTEL\Glpi\GlpiConnector($apiUrl, $appToken, $userToken);

$response = $api->call(
    new Endpoints\Tickets\SearchTicketsRequest()
);

$response = $api->call(
    new Endpoints\Users\GetUserRequest($userId: 100)
);
```

### Using Resources

[](#using-resources)

Using resources is a more convenient way to query the API. Each Resource class groups requests by specific API namespaces (User, Ticket, Profile...).

```
use Illuminate\Support\Collection;
use BlueRockTEL\Glpi\Enums\Operator;
use BlueRockTEL\Glpi\Entities\SearchCriteria;
use BlueRockTEL\Glpi\Entities\Columns\TicketMap;

$api = new BlueRockTEL\Glpi\GlpiConnector($apiUrl, $appToken, $userToken);

$criterias = new Collection([
    new SearchCriteria(
        field: TicketMap::entity_name,
        operator: Operator::CONTAINS,
        value: $entityId,
    ),
    new SearchCriteria(
        field: TicketMap::assigned_id,
        operator: Operator::EQUALS,
        value: $userId,
    ),
]);

$response = $api->ticket()->search(
    isDeleted: false, // only non-deleted tickets
    criterias: $criterias, // set search criterias
    columns: TicketMap::all(), // set the display columns
);
```

Each of those namespace resources can be accessed using the `GlpiConnector` instance :

```
$connector = new GlpiConnector(...);

$connector->user(): BlueRockTEL\Glpi\Resources\UserResource
$connector->profile(): BlueRockTEL\Glpi\Resources\ProfileResource
$connector->ticket(): BlueRockTEL\Glpi\Resources\TicketResource
...
```

If needed, it is also possible to create the desired resource instance manually.

```
use BlueRockTEL\Glpi\GlpiConnector;
use BlueRockTEL\Glpi\Resources\TicketResource;

$api = new GlpiConnector(...);
$resource = new TicketResource($api); // same as $api->ticket()

$ticket = $resource->show($ticketId)->dtoOrFail();

// make changes to $ticket...

$resource->update($ticket);
```

### Responses

[](#responses)

After issuing a request, the returned response is always an instance of `Saloon\Http\Response` class. It provides some useful methods to check the response status and get the response data.

```
// Check response status
$response->ok();
$response->failed();
$response->status();
$response->headers();

// Get response data
$response->json(); # as an array
$response->body(); # as an raw string
$response->dto(); # as a Data Transfer Object
$response->dtoOrFail(); # as a Data Transfer Object, throwing exception on 4-5xx status
```

You can learn more about responses by reading the [Saloon documentation](https://docs.saloon.dev/the-basics/responses#useful-methods), which this client uses underneath.

### Entities (DTO)

[](#entities-dto)

When working with APIs, dealing with a raw or JSON response can be tedious and unpredictable.

To make it easier, this Api client provides a way to transform the response data into a Data Transfer Object (DTO, later called Entities). This way, you are aware of the structure of the data you are working with, and you can access the data using object typed properties instead of untyped array keys.

```
$response = $api->user()->show(id: 92);

/** @var \BlueRockTEL\Glpi\Entities\User */
$user = $response->dtoOrFail();
```

Although you can use the `dto()` method to transform the response data into an entity, it is recommended to use the `dtoOrFail()` method instead. This method will throw an exception if the response status is not 2xx, instead of returning an empty DTO.

It is still possible to access the underlying response object using the `getResponse()` method of the DTO :

```
$entity = $response->dtoOrFail();   // BlueRockTEL\Glpi\Contracts\Entity
$entity->getResponse();             // Saloon\Http\Response
```

> Learn more about working with Data tranfert objects on the [Saloon documentation](https://docs.saloon.dev/digging-deeper/data-transfer-objects).

### Extending the Client

[](#extending-the-client)

You may easily extend the Client by creating your own Resources, Requests, and Entities.

Then, by extending the `GlpiConnector` class, add your new resources to the connector :

```
use BlueRockTEL\Glpi\GlpiConnector;

class MyCustomConnector extends GlpiConnector
{
    public function defaultConfig(): array
    {
        return [
            'timeout' => 30,
        ];
    }

    public function customResource(): \App\Resources\CustomResource
    {
        return new \App\Resources\CustomResource($this);
    }
}

$api = new MyCustomConnector($apiUrl, $appToken, $userToken);
$api->customResource()->index();
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance46

Moderate activity, may be stable

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

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

Total

4

Last Release

402d ago

### Community

Maintainers

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

---

Top Contributors

[![tgeorgel](https://avatars.githubusercontent.com/u/11785727?v=4)](https://github.com/tgeorgel "tgeorgel (9 commits)")

### Embed Badge

![Health badge](/badges/bluerocktel-glpi-php-api-client/health.svg)

```
[![Health](https://phpackages.com/badges/bluerocktel-glpi-php-api-client/health.svg)](https://phpackages.com/packages/bluerocktel-glpi-php-api-client)
```

###  Alternatives

[sandorian/moneybird-api-php

Moneybird API client for PHP

127.3k](/packages/sandorian-moneybird-api-php)[codebar-ag/laravel-docuware

DocuWare integration with Laravel

1221.1k](/packages/codebar-ag-laravel-docuware)[myoutdeskllc/salesforce-php

salesforce library for php8+

1560.8k](/packages/myoutdeskllc-salesforce-php)

PHPackages © 2026

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