Exsited PHP SDK Installation Guide Using Composer
This guide walks you through setting up a CakePHP project and integrating the Exsited PHP SDK via Composer. It includes installation steps, configuration of authentication, and making API calls through CakePHP controllers. By the end, your app will be able to authenticate and interact with Exsited's APIs.
Prerequisites
Ensure you have the following tools installed:
- PHP: Version 7.0 or higher
- Composer: Dependency manager for PHP
- XAMPP: For local server and database
- CakePHP: PHP framework (installed via Composer)
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 Developers)
Edit config/app.php
and update the Datasources
section with your database credentials.
Skip if you're just testing SDK calls.
Installing the SDK via Composer
Step 1: Run the Composer Command
Inside your CakePHP project root:
composer require exsitedapi/exsited-sdk:dev-main
This installs the SDK into vendor/exsitedapi/exsited-sdk
.
SDK Configuration
Step 1: Navigate to the SDK Directory
cd vendor/exsitedapi/exsited-sdk
Step 2: Create SDK Config File
In the root directory of the cloned SDK project, ensure there is a file named sdk-config.json
. If it doesn't exist, create one manually.
{
"apiVersion": "v3",
"reQuestTimeOut": 240
}
Explanation of SDK Config Fields
Key | Description |
---|---|
apiVersion | The default API version to be used by the SDK (e.g., "v3" ). |
reQuestTimeOut | The request timeout limit (in seconds) for API calls. Helps prevent hanging requests on slow connections. |
⚠️ File and field names are case-sensitive. Be sure to spell
"reQuestTimeOut"
exactly as shown above.
Step 3: Create Token File
Next, verify that a file named token.json
exists in the root directory of the SDK. If not, create it manually.
You can now include one or more sets of credentials inside a JSON array like this:
[
{
"apiUrl": "[EXSITED_API_BASE_URL]",
"appUrl": "[EXSITED_APP_URL]",
"client_id": "[YOUR_CLIENT_ID]",
"client_secret": "[YOUR_CLIENT_SECRET]",
"access_token": "[YOUR_ACCESS_TOKEN]",
"refresh_token": "[YOUR_REFRESH_TOKEN]",
"redirect_uri": "[YOUR_REDIRECT_URI]",
"authTokenRenewCallback": {}
},
{
"apiUrl": "[EXSITED_API_BASE_URL]",
"appUrl": "[EXSITED_APP_URL]",
"client_id": "[YOUR_CLIENT_ID]",
"client_secret": "[YOUR_CLIENT_SECRET]",
"access_token": "[YOUR_ACCESS_TOKEN]",
"refresh_token": "[YOUR_REFRESH_TOKEN]",
"redirect_uri": "[YOUR_REDIRECT_URI]",
"authTokenRenewCallback": {}
}
]
Explanation of Token File Fields
Key | Description |
---|---|
client_id | Your provided Client ID |
client_secret | Your provided Client Secret |
redirect_uri | Your authorized Redirect URL |
apiUrl | API base URL (e.g., staging or live) |
appUrl | App base URL |
Important Notes
- You can include multiple credential objects in an array format.
- Each object must be properly formatted and comma-separated.
- If using multiple accounts or environments, the SDK may provide a mechanism to select the appropriate configuration dynamically.