geniza-ai/geniza-sdk-php

SDK for interacting with Geniza.ai API endpoints

v0.3.1 2023-12-22 18:31 UTC

README

Php_version Package version License

This SDK is the best and easiest way to connect to the Geniza.ai API.

Installation

Install using composer:

composer require geniza-ai/geniza-sdk-php

Usage

use Geniza\Geniza;

new Geniza($key, $secretKey);

Detailed information on how to use the methods contained in this SDK can be found on in our API documentation.

Framework Integrations

CodeIgniter 4

Add the key and secret key to a config class.

<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;

class Geniza extends BaseConfig {
	public string $key = '';
	public string $secretKey = '';
}

Note: These values should be set and overridden by your environment variables.

Add the following to your \Config\Services.php file:

	public static function geniza(bool $getShared = true) {
		if($getShared) {
			return static::getSharedInstance('geniza');
		}

		return new \Geniza\Geniza(
			config('Geniza')->key,
			config('Geniza')->secretKey
		);
	}

You can then instantiate your Geniza handle by simply calling the service method:

	$geniza = \Config\Services::geniza(true);

Laravel

This is an example service provider which registers a shared Optimus instance for your entire application:

<?php

namespace App\Providers;

use Geniza\Geniza;
use Illuminate\Support\ServiceProvider;

class GenizaServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->singleton(Geniza::class, function ($app) {
            $key = 'abcd1234';
            $secretKey = 'efgh5678';
            return new Geniza($key, $secretKey);
        });
    }
}

Once you have created the service provider, add it to the providers array in your config/app.php configuration file:

App\Providers\GenizaServiceProvider::class,

More information: https://laravel.com/docs/5.3/container#resolving