hostme / php-sdk
HostMe PHP SDK
dev-master / 1.0.x-dev
2017-08-11 14:58 UTC
Requires
- php: ^7.0
- guzzlehttp/guzzle-services: ^1.1
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is auto-updated.
Last update: 2024-08-26 23:39:39 UTC
README
HostMe SDK for PHP 允许 PHP 开发者轻松将我们的 API 集成到您的应用程序中。
注意:此库正在积极开发中,许多调用尚未实现。我们期待您的任何 PR。
安装
我们建议使用 Composer 来管理依赖项。安装就像这样一样简单
$ composer require "hostme/php-sdk:1.0.*@dev"
使用
<?php
$config = [
// ...
];
$client = new \HostMe\Client($config);
配置参考
<?php
$config = [
'oauth' => [
'oauth_endpoint' => 'https://.../oauth/v2/token',
'client_id' => '123',
'client_secret' => 's$cr$t',
'api_key' => 's$cr$t123',
],
'box_endpoint' => 'https://.../',
'user_endpoint' => 'https://.../',
'app_endpoint' => 'https://.../',
'task_endpoint' => 'https://.../',
'platform_endpoint' => 'https://.../api/',
];
桥接 Symfony
服务定义
services:
app.token_authenticator:
class: HostMe\Brige\Symfony\Security\Guard\TokenAuthenticator
app.token_provider:
class: HostMe\Brige\Symfony\Security\Provider\TokenProvider
arguments:
- "@app.hostme"
app.hostme:
class: HostMe\Client
arguments:
-
oauth:
oauth_endpoint: "%user.oauth.oauth_endpoint%"
client_id: "%user.oauth.client_id%"
client_secret: "%user.oauth.client_secret%"
api_key: "%user.oauth.api_key%"
在安全方面
security:
providers:
token:
id: app.token_provider
role_hierarchy:
ROLE_API: ROLE_USER
ROLE_ADMIN: ROLE_API
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: ~
logout: ~
guard:
authenticators:
- app.token_authenticator
stateless: true
access_control:
- { path: ^/, roles: [ ROLE_API ] }