filippo-toso/alleantia-sdk

Alleantia IOT Server unofficial PHP SDK

v1.0.6 2023-09-25 06:22 UTC

This package is auto-updated.

Last update: 2024-11-25 08:43:21 UTC


README

A simple SDK to access Alleantia IOT Server Rest APIs (version 2.3).

Requirements

  • PHP 8.0+

Installing

Use Composer to install it:

composer require filippo-toso/alleantia-sdk

If you don't already have an implementation for psr/http-factory and psr/http-client, you should execute also:

composer require php-http/curl-client laminas/laminas-diactoros

Vanilla PHP usage

Create the SDK instance and call the various endpoints.

use FilippoToso\Alleantia\Alleantia;
use FilippoToso\Alleantia\Options;

require(__DIR__ . '/../vendor/autoload.php');

$options = new Options([
    'base_url' => 'http://192.168.1.123:8081',
    'username' => 'admin',
    'password' => 'secret',
]);

$alleantia = new Alleantia($options);

$response = $alleantia->system()->info();

print_r($response->body());

Laravel usage

In your config/services.php files add:

return [
    
    // ...
    
    'alleantia' => [
        'base_url' => env('ALLEANTIA_BASE_URL'),
        'username' => env('ALLEANTIA_USERNAME'),
        'password' => env('ALLEANTIA_PASSWORD'),
    ],   
];

In your .env file, add the following variables:

ALLEANTIA_BASE_URL=http://192.168.1.123:8081
ALLEANTIA_USERNAME=admin
ALLEANTIA_PASSWORD=secret

In your Laravel code:

use FilippoToso\Alleantia\Laravel\Alleantia;

$response = Alleantia::system()->info();

dump($response->body());