PHPackages                             templatemonster/zohocrm-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. templatemonster/zohocrm-php-sdk

ActiveSdk[API Development](/categories/api)

templatemonster/zohocrm-php-sdk
===============================

Zoho CRM API SDK for PHP

3.1.2(3y ago)0266PHPPHP &gt;=7.0

Since Apr 19Pushed 3y agoCompare

[ Source](https://github.com/Plasma-Platform/zohocrm-php-sdk)[ Packagist](https://packagist.org/packages/templatemonster/zohocrm-php-sdk)[ Docs](https://github.com/Plasma-Platform/zohocrm-php-sdk)[ RSS](/packages/templatemonster-zohocrm-php-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Archival Notice:
================

[](#archival-notice)

This SDK is archived. You can continue to use it, but no new features or support requests will be accepted. For the new version, refer to

ZOHO CRM v2 API SDK:

- [GitHub Repository](https://github.com/zoho/zohocrm-php-sdk-2.0)
- [Help Doc](https://www.zoho.com/crm/developer/docs/php-sdk/v2/php.html)

ZOHO CRM v2.1 API SDK:

- [GitHub Repository](https://github.com/zoho/zohocrm-php-sdk-2.1)

ZOHO CRM PHP SDK
================

[](#zoho-crm-php-sdk)

Table Of Contents
-----------------

[](#table-of-contents)

- [Overview](#overview)
- [Registering a Zoho Client](#registering-a-zoho-client)
- [Environmental Setup](#environmental-setup)
- [Including the SDK in your project](#including-the-sdk-in-your-project)
- [Persistence](#token-persistence)
    - [DataBase Persistence](#database-persistence)
    - [File Persistence](#file-persistence)
    - [Custom Persistence](#custom-persistence)
- [Configuration](#configuration)
- [Initialization](#initializing-the-application)
- [Class Hierarchy](#class-hierarchy)
- [Responses And Exceptions](#responses-and-exceptions)
- [Multi-User support in the PHP SDK](#multi-user-support-in-the-php-sdk)
- [Sample Code](#sdk-sample-code)

Overview
--------

[](#overview)

Zoho CRM PHP SDK offers a way to create client PHP applications that can be integrated with Zoho CRM.

Registering a Zoho Client
-------------------------

[](#registering-a-zoho-client)

Since Zoho CRM APIs are authenticated with OAuth2 standards, you should register your client app with Zoho. To register your app:

- Visit this page [https://api-console.zoho.com/](https://api-console.zoho.com)
- Click on `ADD CLIENT`.
- Choose a `Client Type`.
- Enter **Client Name**, **Client Domain** or **Homepage URL** and **Authorized Redirect URIs** then click `CREATE`.
- Your Client app would have been created and displayed by now.
- Select the created OAuth client.
- Generate grant token by providing the necessary scopes, time duration (the duration for which the generated token is valid) and Scope Description.

Environmental Setup
-------------------

[](#environmental-setup)

PHP SDK is installable through **Composer**. **Composer** is a tool for dependency management in PHP. SDK expects the following from the client app.

- Client app must have PHP(version 7 and above) with curl extension enabled.
- PHP SDK must be installed into client app though **Composer**.

Including the SDK in your project
---------------------------------

[](#including-the-sdk-in-your-project)

You can include the SDK to your project using:

- Install **Composer** (if not installed).

    - Run this command to install the composer.

        ```
        curl -sS https://getcomposer.org/installer | php
        ```
    - To install composer on mac/linux machine:

        ```
        https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx
        ```
    - To install composer on windows machine:

        ```
        https://getcomposer.org/doc/00-intro.md#installation-windows
        ```
- Install **PHP SDK**.

    - Navigate to the workspace of your client app.
    - Run the command below:

        ```
        composer require zohocrm/php-sdk:3.1.0
        ```
    - The PHP SDK will be installed and a package named vendor will be created in the workspace of your client app.
- Using the SDK.

    - Add the below line in PHP files of your client app, where you would like to make use of PHP SDK.

        ```
        require 'vendor/autoload.php';
        ```

    Through this line, you can access all the functionalities of the PHP SDK. The namespaces of the class to be used must be included within the "use" statement.

Token Persistence
-----------------

[](#token-persistence)

Token persistence refers to storing and utilizing the authentication tokens that are provided by Zoho. There are three ways provided by the SDK in which persistence can be utilized. They are DataBase Persistence, File Persistence and Custom Persistence.

### Table of Contents

[](#table-of-contents-1)

- [DataBase Persistence](#database-persistence)
- [File Persistence](#file-persistence)
- [Custom Persistence](#custom-persistence)

### Implementing OAuth Persistence

[](#implementing-oauth-persistence)

Once the application is authorized, OAuth access and refresh tokens can be used for subsequent user data requests to Zoho CRM. Hence, they need to be persisted by the client app.

The persistence is achieved by writing an implementation of the inbuilt **TokenStore interface**, which has the following callback methods.

- **getToken($user, $token)** - invoked before firing a request to fetch the saved tokens. This method should return an implementation of **Token interface** object for the library to process it.
- **saveToken($user, $token)** - invoked after fetching access and refresh tokens from Zoho.
- **deleteToken($token)** - invoked before saving the latest tokens.
- **getTokens()** - The method to retrieve all the stored tokens.
- **deleteTokens()** - The method to delete all the stored tokens.

Note:

- $user instanceof UserSignature.
- $token instanceof Token interface.

### DataBase Persistence

[](#database-persistence)

In case the user prefers to use the default DataBase persistence, **MySQL** can be used.

- The database name should be **zohooauth**.
- There must be a table name oauthtoken with columns.

    - user\_mail varchar(255)
    - client\_id varchar(255)
    - refresh\_token varchar(255)
    - access\_token varchar(255)
    - grant\_token varchar(255)
    - expiry\_time varchar(20)

#### MySQL Query

[](#mysql-query)

```
create table oauthtoken(id int(11) not null auto_increment, user_mail varchar(255) not null, client_id varchar(255), refresh_token varchar(255), access_token varchar(255), grant_token varchar(255), expiry_time varchar(20), primary key (id));

alter table oauthtoken auto_increment = 1;
```

#### Create DBStore object

[](#create-dbstore-object)

```
/*
* 1 -> DataBase host name. Default value "localhost"
* 2 -> DataBase name. Default  value "zohooauth"
* 3 -> DataBase user name. Default value "root"
* 4 -> DataBase password. Default value ""
* 5 -> DataBase port number. Default value "3306"
*/
$tokenstore = new DBStore();

$tokenstore = new DBStore("hostName", "dataBaseName", "userName", "password", "portNumber");
```

### File Persistence

[](#file-persistence)

In case of default File Persistence, the user can persist tokens in the local drive, by providing the the absolute file path to the FileStore object.

- The File contains.

    - user\_mail
    - client\_id
    - refresh\_token
    - access\_token
    - grant\_token
    - expiry\_time

#### Create FileStore object

[](#create-filestore-object)

```
//Parameter containing the absolute file path to store tokens
$tokenstore = new FileStore("/Users/username/Documents/php_sdk_token.txt");
```

### Custom Persistence

[](#custom-persistence)

To use Custom Persistence, the user must implement **TokenStore interface** (**com\\zoho\\api\\authenticator\\store\\TokenStore**) and override the methods.

```
namespace store;

use com\zoho\api\authenticator\Token;

use com\zoho\crm\api\exception\SDKException;

use com\zoho\crm\api\UserSignature;

use com\zoho\api\authenticator\store\TokenStore;

class CustomStore implements TokenStore
{
    /**
        * @param user A UserSignature class instance.
        * @param token A Token (com\zoho\api\authenticator\OAuthToken) class instance.
        * @return A Token class instance representing the user token details.
        * @throws SDKException if any problem occurs.
    */
    public function getToken($user, $token)
    {
        // Add code to get the token
        return null;
    }

    /**
        * @param user A UserSignature class instance.
        * @param token A Token (com\zoho\api\authenticator\OAuthToken) class instance.
        * @throws SDKException if any problem occurs.
    */
    public function saveToken($user, $token)
    {
        // Add code to save the token
    }

    /**
        * @param token A Token (com\zoho\api\authenticator\OAuthToken) class instance.
        * @throws SDKException if any problem occurs.
    */
    public function deleteToken($token)
    {
        // Add code to delete the token
    }

  /**
   * @return array  An array of Token (com\zoho\api\authenticator\OAuthToken) class instances
   */
    public function getTokens()
    {
        //Add code to retrieve all the stored tokens
    }

    public function deleteTokens()
    {
        //Add code to delete all the stored tokens.
    }
}
```

Configuration
-------------

[](#configuration)

Before you get started with creating your PHP application, you need to register your client and authenticate the app with Zoho.

- Create an instance of **Logger** Class to log exception and API information.

    ```
    /*
    * Create an instance of Logger Class that takes two parameters
    * 1 -> Level of the log messages to be logged. Can be configured by typing Levels "::" and choose any level from the list displayed.
    * 2 -> Absolute file path, where messages need to be logged.
    */
    $logger = Logger::getInstance(Levels::INFO, "/Users/user_name/Documents/php_sdk_log.log");
    ```
- Create an instance of **UserSignature** that identifies the current user.

    ```
    //Create an UserSignature instance that takes user Email as parameter
    $user = new UserSignature("abc@zoho.com");
    ```
- Configure API environment which decides the domain and the URL to make API calls.

    ```
    /*
    * Configure the environment
    * which is of the pattern Domain.Environment
    * Available Domains: USDataCenter, EUDataCenter, INDataCenter, CNDataCenter, AUDataCenter
    * Available Environments: PRODUCTION(), DEVELOPER(), SANDBOX()
    */
    $environment = USDataCenter::PRODUCTION();
    ```
- Create an instance of OAuthToken with the information that you get after registering your Zoho client.

    ```
    /*
    * Create a Token instance
    * 1 -> OAuth client id.
    * 2 -> OAuth client secret.
    * 3 -> REFRESH/GRANT token.
    * 4 -> Token type(REFRESH/GRANT).
    * 5 -> OAuth redirect URL. (optional)
    */
    $token = new OAuthToken("clientId", "clientSecret", "REFRESH/GRANT token", TokenType::REFRESH/GRANT, "redirectURL");
    ```
- Create an instance of TokenStore to persist tokens, used for authenticating all the requests.

    ```
    /*
    * Create an instance of DBStore.
    * 1 -> DataBase host name. Default value "localhost"
    * 2 -> DataBase name. Default  value "zohooauth"
    * 3 -> DataBase user name. Default value "root"
    * 4 -> DataBase password. Default value ""
    * 5 -> DataBase port number. Default value "3306"
    */
    //$tokenstore = new DBStore();

    $tokenstore = new DBStore("hostName", "dataBaseName", "userName", "password", "portNumber");

    // $tokenstore = new FileStore("absolute_file_path");
    ```
- Create an instance of SDKConfig containing SDK configurations.

    ```
    /*
    * autoRefreshFields (default value is false)
    * true - all the modules' fields will be auto-refreshed in the background, every hour.
    * false - the fields will not be auto-refreshed in the background. The user can manually delete the file(s) or refresh the fields using methods from ModuleFieldsHandler(com\zoho\crm\api\util\ModuleFieldsHandler)
    *
    * pickListValidation (default value is true)
    * A boolean field that validates user input for a pick list field and allows or disallows the addition of a new value to the list.
    * true - the SDK validates the input. If the value does not exist in the pick list, the SDK throws an error.
    * false - the SDK does not validate the input and makes the API request with the user’s input to the pick list
    *
    * enableSSLVerification (default value is true)
    * A boolean field to enable or disable curl certificate verification
    * true - the SDK verifies the authenticity of certificate
    * false - the SDK skips the verification
    */
    $autoRefreshFields = false;

    $pickListValidation = false;

    $enableSSLVerification = true;

    $connectionTimeout = 2; //The number of seconds to wait while trying to connect. Use 0 to wait indefinitely.

    $timeout = 2; //The maximum number of seconds to allow cURL functions to execute.

    $sdkConfig = (new SDKConfigBuilder())->setAutoRefreshFields($autoRefreshFields)->setPickListValidation($pickListValidation)->setSSLVerification($enableSSLVerification)->connectionTimeout($connectionTimeout)->timeout($timeout)->build();
    ```
- Create an instance of RequestProxy containing the proxy properties of the user.

    ```
     $requestProxy = new RequestProxy("proxyHost", "proxyPort", "proxyUser", "password");
    ```
- The path containing the absolute directory path to store user specific files containing module fields information.

    ```
    $resourcePath = "/Users/user_name/Documents/phpsdk-application";
    ```

Initializing the Application
----------------------------

[](#initializing-the-application)

Initialize the SDK using the following code.

```

```

- You can now access the functionalities of the SDK. Refer to the sample codes to make various API calls through the SDK.

Class Hierarchy
---------------

[](#class-hierarchy)

[![classdiagram](class_hierarchy.png)](class_hierarchy.png)

Responses and Exceptions
------------------------

[](#responses-and-exceptions)

All SDK method calls return an instance of the **APIResponse** class.

Use the **getObject()** method in the returned **APIResponse** object to obtain the response handler interface depending on the type of request (**GET, POST,PUT,DELETE**).

**APIResponse&lt;ResponseHandler&gt;** and **APIResponse&lt;ActionHandler&gt;** are the common wrapper objects for Zoho CRM APIs’ responses.

Whenever the API returns an error response, the response will be an instance of **APIException** class.

All other exceptions such as SDK anomalies and other unexpected behaviours are thrown under the **SDKException** class.

- For operations involving records in Tags

    - **APIResponse&lt;RecordActionHandler&gt;**
- For getting Record Count for a specific Tag operation

    - **APIResponse&lt;CountHandler&gt;**
- For operations involving BaseCurrency

    - **APIResponse&lt;BaseCurrencyActionHandler&gt;**
- For Lead convert operation

    - **APIResponse&lt;ConvertActionHandler&gt;**
- For retrieving Deleted records operation

    - **APIResponse&lt;DeletedRecordsHandler&gt;**
- For Record image download operation

    - **APIResponse&lt;DownloadHandler&gt;**
- For MassUpdate record operations

    - **APIResponse&lt;MassUpdateActionHandler&gt;**
    - **APIResponse&lt;MassUpdateResponseHandler&gt;**

### GET Requests

[](#get-requests)

- The **getObject()** of the returned APIResponse instance returns the response handler interface.
- The **ResponseHandler interface** interface encompasses the following

    - **ResponseWrapper class** (for **application/json** responses)
    - **FileBodyWrapper class** (for File download responses)
    - **APIException class**
- The **CountHandler interface** encompasses the following

    - **CountWrapper class** (for **application/json** responses)
    - **APIException class**
- The **DeletedRecordsHandler interface** encompasses the following

    - **DeletedRecordsWrapper class** (for **application/json** responses)
    - **APIException class**
- The **DownloadHandler interface** encompasses the following

    - **FileBodyWrapper class** (for File download responses)
    - **APIException class**
- The **MassUpdateResponseHandler interface** encompasses the following

    - **MassUpdateResponseWrapper class** (for **application/json** responses)
    - **APIException class**

### POST, PUT, DELETE Requests

[](#post-put-delete-requests)

- The **getObject()** of the returned APIResponse instance returns the action handler interface.
- The **ActionHandler interface** encompasses the following

    - **ActionWrapper class** (for **application/json** responses)
    - **APIException class**
- The **ActionWrapper class** contains **Property/Properties** that may contain one/list of **ActionResponse interfaces**.
- The **ActionResponse interface** encompasses following

    - **SuccessResponse class** (for **application/json** responses)
    - **APIException class**
- The **ActionHandler interface** encompasses following

    - **ActionWrapper class** (for **application/json** responses)
    - **APIException class**
- The **RecordActionHandler interface** encompasses following

    - **RecordActionWrapper class** (for **application/json** responses)
    - **APIException class**
- The **BaseCurrencyActionHandler interface** encompasses following

    - **BaseCurrencyActionWrapper class** (for **application/json** responses)
    - **APIException class**
- The **MassUpdateActionHandler interface** encompasses following

    - **MassUpdateActionWrapper class** (for **application/json** responses)
    - **APIException class**
- The **ConvertActionHandler interface** encompasses following

    - **ConvertActionWrapper class** (for **application/json** responses)
    - **APIException class**

Multi-User support in the PHP SDK
---------------------------------

[](#multi-user-support-in-the-php-sdk)

The **PHP SDK** (from version 3.x.x) supports both single user and a multi-user app.

### Multi-user App

[](#multi-user-app)

Multi-users functionality is achieved using Initializer's static **switchUser()**.

```
Initializer::switchUser($user, $environment, $token, $sdkConfig, $proxy);
```

To Remove a user's configuration in SDK. Use the below code

```
Initializer::removeUserConfiguration($user, $environment);
```

```

```

- The program execution starts from main().
- The details of **"user1"** are is given in the variables user1, token1, environment1.
- Similarly, the details of another user **"user2"** is given in the variables user2, token2, environment2.
- Then, the **switchUser()** function is used to switch between the **"user1"** and **"user2"** as required.
- Based on the latest switched user, the **$this-&gt;getRecords($moduleAPIName)** will fetch record.

SDK Sample code
---------------

[](#sdk-sample-code)

```

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1116d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5a155b7be23704de5be0dcb5d2b543736a2e9765ea2eb7e6103fb28307bf2b9b?d=identicon)[ch-tm](/maintainers/ch-tm)

---

Top Contributors

[![raja-k-7453](https://avatars.githubusercontent.com/u/45655127?v=4)](https://github.com/raja-k-7453 "raja-k-7453 (18 commits)")[![Aswin97](https://avatars.githubusercontent.com/u/13204450?v=4)](https://github.com/Aswin97 "Aswin97 (8 commits)")[![ch-tm](https://avatars.githubusercontent.com/u/22640796?v=4)](https://github.com/ch-tm "ch-tm (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/templatemonster-zohocrm-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/templatemonster-zohocrm-php-sdk/health.svg)](https://phpackages.com/packages/templatemonster-zohocrm-php-sdk)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M452](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
