geniza-ai / geniza-sdk-php
用于与Geniza.ai API端点交互的SDK
v0.3.1
2023-12-22 18:31 UTC
Requires
- php: ^8.1
- ext-json: *
- guzzlehttp/guzzle: ^7.7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^v3.23.0
- nexusphp/cs-config: ^v3.14.4
- phpstan/extension-installer: *
- phpstan/phpstan: *
- phpstan/phpstan-strict-rules: *
- phpunit/phpunit: ^10.3.2
- rector/rector: 0.18.12
- roave/security-advisories: dev-latest
- sebastian/phpcpd: *
- vimeo/psalm: *
Suggests
- ext-curl: Helpful in interacting with Geniza.ai API servers.
- ext-openssl: Always a good idea
This package is auto-updated.
Last update: 2024-09-08 02:38:10 UTC
README
此SDK是与Geniza.ai API连接的最佳和最简单的方式。
安装
使用composer安装
composer require geniza-ai/geniza-sdk-php
使用方法
use Geniza\Geniza; new Geniza($key, $secretKey);
有关如何使用此SDK中包含的方法的详细信息,请参阅我们的API文档。
框架集成
CodeIgniter 4
将密钥和密钥添加到配置类中。
<?php namespace Config; use CodeIgniter\Config\BaseConfig; class Geniza extends BaseConfig { public string $key = ''; public string $secretKey = ''; }
注意:这些值应由您的环境变量设置和覆盖。
将以下内容添加到您的\Config\Services.php
文件中
public static function geniza(bool $getShared = true) { if($getShared) { return static::getSharedInstance('geniza'); } return new \Geniza\Geniza( config('Geniza')->key, config('Geniza')->secretKey ); }
然后,您可以通过调用服务方法简单地实例化您的Geniza处理程序
$geniza = \Config\Services::geniza(true);
Laravel
这是一个示例服务提供程序,它为您的整个应用程序注册一个共享的Optimus实例
<?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); }); } }
创建服务提供程序后,将其添加到配置文件config/app.php
中的提供者数组中
App\Providers\GenizaServiceProvider::class,