hyperized/hostfact

Hostfact 3.0 API Implementation for Laravel

v4.0.0 2022-12-06 13:28 UTC

README

FOSSA Status

Official documentation:

Installation

Install using composer:

composer require hyperized/hostfact

This package supports Package Auto-Discovery (Laravel 5.5+) so it doesn't require you to manually add the ServiceProvider and alias.

If you are using a lower version of Laravel or not using Auto-Discovery you can add the Hostfact Service Provider to the config/app.php file

Hyperized\Hostfact\HostfactServiceProvider::class,

Register an alias for Hostfact, also in config/app.php:

'Hostfact'    => Hyperized\Hostfact\HostfactServiceProvider::class,

Now publish the Hostfact package into your installation:

php artisan vendor:publish --provider="Hyperized\Hostfact\HostfactServiceProvider" --tag="config"

This should give you a message like: Copied File [/vendor/hyperized/hostfact/config/Hostfact.php] To [/config/Hostfact.php]

It's possible to edit your configuration variables in the config/Hostfact.php file or you can use the HOSTFACT_URL and HOSTFACT_KEY environment variables to store sensitive information in the .env file

// config/Hostfact.php
'api_v2_url'		=> env('HOSTFACT_URL', 'https://yoursite.tld/Pro/apiv2/api.php'),
'api_v2_key'		=> env('HOSTFACT_KEY', 'token'),
'api_v2_timeout'	=> env('HOSTFACT_TIMEOUT', 20),

// .env/.env.example
HOSTFACT_URL=https://yoursite.tld/Pro/apiv2/api.php
HOSTFACT_KEY=token
HOSTFACT_TIMEOUT=20

Functionality

When writing code for this Hostfact package, consider that this package has been written as a basic interface.

This package will do the following:

  • Provide an easy way to communicate with Hostfact API controllers;
  • Document the available API controller endpoints with methods;
  • Transport layer (HTTP/HTTPS) error catching;
  • Basic error parsing;

This package will not:

  • Parameter / input validation;
  • Output validation;

You will need to consult the Hostfact API documentation to understand the acceptable input and output for each of the API controllers.

Examples

Example code:

use \Hyperized\Hostfact\Api\Controllers\Product;

$products = Product::new()
                ->list([
                    'searchfor' => 'invoice'
                ]);

License

FOSSA Status