1. Go to this page and download the library: Download royfee/basesdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
royfee / basesdk example snippets
use Royfee\BaseSdk\Application;
use Royfee\BaseSdk\Api\AbstractApi;
use Royfee\BaseSdk\Http\Middleware\AuthMiddleware;
use Royfee\BaseSdk\Http\Middleware\RetryMiddleware;
// 1. Create the application
$app = new Application([
'app_id' => 'your-app-id',
'secret' => 'your-secret',
'debug' => true,
'log' => [
'file' => __DIR__ . '/logs/sdk.log',
'level' => 'debug',
],
]);
// 2. Define your API class
class MyApi extends AbstractApi
{
public function registerMiddlewares(): void
{
$this->addMiddleware(new AuthMiddleware($this->app['access_token']));
$this->addMiddleware(new RetryMiddleware(3, 500));
}
public function getUsers(): array
{
return $this->get('/users')->toArray();
}
public function createUser(array $data): array
{
return $this->postJson('/users', $data)->toArray();
}
}
// 3. Use it
$api = new MyApi($app);
$users = $api->getUsers();
bash
composer analyse
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.