Download the PHP package bluerocktel/glpi-php-api-client without Composer

On this page you can find all versions of the php package bluerocktel/glpi-php-api-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package glpi-php-api-client

php-sdk

Latest Version on Packagist Total Downloads

This package is a light PHP Wrapper / SDK for the GLPI Project API.

Installation

This library requires PHP >=8.1.

You can install the package via composer:

Authentication

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 :

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 :

Usage

To query the API, you can either call each API Endpoints requests individually, or make use of provided Resources classes which groups the requests into clusters.

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 :

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...).

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

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

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.

You can learn more about responses by reading the Saloon documentation, which this client uses underneath.

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.

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 :

Learn more about working with Data tranfert objects on the Saloon documentation.

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 :


All versions of glpi-php-api-client with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
nesbot/carbon Version ^2.68|^3.0
illuminate/collections Version >=9.0
saloonphp/saloon Version ^3.0
saloonphp/rate-limit-plugin Version ^2.0
saloonphp/pagination-plugin Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package bluerocktel/glpi-php-api-client contains the following files

Loading the files please wait ....