mydemovendor / mydemopackage
PHP SDK for the Exsited API
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/mydemovendor/mydemopackage
Requires
- php-http/client-common: ^2.7
- psr/http-client: ^1.0
- psr/http-factory: ^1.1
- psr/http-message: ^1.1
- vlucas/phpdotenv: ^5.6
Requires (Dev)
- laminas/laminas-diactoros: ^2.0 || ^3.0
- php-http/curl-client: ^2.3
This package is not auto-updated.
Last update: 2025-12-22 12:24:07 UTC
README
This document provides step-by-step instructions for setting up a CakePHP project and integrating it with the Exsited PHP SDK. Follow this guide to create the project, install the SDK, configure authentication, and make API calls.
Table of Contents
- Prerequisites
- Project Setup
- Installing the SDK
- Configuration
- Authentication Setup
- Making API Calls Using the SDK
1. Prerequisites
Ensure you have the following installed:
- PHP: Version 7.0 or higher
- XAMPP: For local development and testing
- Composer: Dependency management
- CakePHP: PHP framework for the project
2. Project Setup
Step 1: Create a New CakePHP Project
composer create-project --prefer-dist cakephp/app my_cakephp_project
cd my_cakephp_project
Step 2: Configure Database (Optional for Testing)
- Edit
config/app.php - Update the
Datasourcessection with your database credentials. - Ensure XAMPP is running and the database is accessible.
3. Installing the SDK
Step 1: Install the SDK Package
composer require exsitedapi/exsited-sdk:dev-main --with-all-dependencies
Step 2: Verify Installation
- SDK should be located at:
vendor/apidemo/autobill-sdkdemo
4. Configuration
Step 1: Create token.json
In vendor/apidemo/autobill-sdkdemo/, create token.json:
[
{
"apiUrl": "https://api-stage.exsited.com/",
"appUrl": "https://api-stage.exsited.com/",
"client_id": "[YOUR_CLIENT_ID]",
"client_secret": "[YOUR_CLIENT_SECRET]",
"access_token": "[YOUR_ACCESS_TOKEN]",
"refresh_token": "[YOUR_REFRESH_TOKEN]",
"redirect_uri": "https://www.google.com",
"authTokenRenewCallback": {}
}
]
Step 2: Create sdk-config.json
{
"apiVersion": "v3",
"reQuestTimeOut": 240
}
5. Authentication Setup
Update token.json with actual credentials:
| Key | Value |
|---|---|
client_id |
[YOUR_CLIENT_ID] |
client_secret |
[YOUR_CLIENT_SECRET] |
redirect_uri |
[YOUR_REDIRECT_URI] |
apiUrl |
[YOUR_API_URL] |
appUrl |
[YOUR_APP_URL] |
6. Making API Calls Using the SDK
Step 1: Create SDK Controller
src/Controller/SdkController.php
<?php namespace App\Controller; use Cake\Controller\Controller; use Api\Component\ApiConfig; use Api\AppService\Account\AccountData; use Api\ApiHelper\Config\ConfigManager; class SdkController extends Controller { public function initialize(): void { parent::initialize(); $this->loadComponent('RequestHandler'); } public function getAccountData() { $this->autoRender = false; $configManager = new ConfigManager(); $apiConfig = new ApiConfig($configManager->getConfig()); $accountService = new AccountData($apiConfig); try { $response = $accountService->readAll('v3'); $this->response = $this->response->withType('application/json')->withStringBody(json_encode(['response' => $response])); } catch (\Exception $e) { $this->response = $this->response->withType('application/json')->withStringBody(json_encode(['error' => $e->getMessage()])); } } public function accountCreate() { $this->autoRender = false; $params = ["name" => "abcde", "email_address" => "basicinformationsami123@gmail.com"]; $configManager = new ConfigManager(); $apiConfig = new ApiConfig($configManager->getConfig()); $accountService = new AccountData($apiConfig); try { $response = $accountService->create($params, 'v2'); $this->response = $this->response->withType('application/json')->withStringBody(json_encode($response, JSON_PRETTY_PRINT)); } catch (\Exception $e) { $error = ['error' => $e->getMessage()]; $this->response = $this->response->withType('application/json')->withStringBody(json_encode($error, JSON_PRETTY_PRINT)); } } }
Step 2: Add Routes
In config/routes.php:
$builder->connect('/sdk/account-data', ['controller' => 'Sdk', 'action' => 'getAccountData']); $builder->connect('/sdk/account-create', ['controller' => 'Sdk', 'action' => 'accountCreate']);
Step 3: Start the Server
Option 1: Using XAMPP
- Move project folder to
htdocsdirectory. - Visit:
http://localhost/my_cakephp_project/sdk/account-create
Option 2: Using Built-in PHP Server
bin/cake server
Visit: http://localhost:8765/sdk/account-create
Authentication Workflow with API Versioning
- If no version is specified, the SDK uses the version from
sdk-config.json. - Explicit version overrides
sdk-config.jsonfor specific API calls.
Conclusion
Your CakePHP project is now configured with the Exsited PHP SDK and ready to make API calls. For issues, verify credentials and configurations.