PHPackages                             jithvar/yii2-ringcentral - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. jithvar/yii2-ringcentral

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

jithvar/yii2-ringcentral
========================

Send Fax using RingCentral with Yii2

v1.3.0(1y ago)011MITPHPPHP &gt;=7.4.0

Since Jan 10Pushed 1y agoCompare

[ Source](https://github.com/jithvar/yii2-ringcentral)[ Packagist](https://packagist.org/packages/jithvar/yii2-ringcentral)[ RSS](/packages/jithvar-yii2-ringcentral/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (9)Used By (0)

Yii2 RingCentral Fax Extension
==============================

[](#yii2-ringcentral-fax-extension)

This extension provides RingCentral Fax integration for Yii2 framework with OAuth 2.0 support.

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist jithvar/yii2-ringcentral

```

or add

```
"jithvar/yii2-ringcentral": "*"

```

to the require section of your `composer.json` file.

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

[](#configuration)

### Basic Configuration

[](#basic-configuration)

```
'components' => [
    'ringcentralFax' => [
        'class' => 'ringcentral\fax\RingCentralFax',
        'clientId' => 'YOUR_CLIENT_ID',
        'clientSecret' => 'YOUR_CLIENT_SECRET',
        'serverUrl' => 'https://platform.ringcentral.com', // Use 'https://platform.devtest.ringcentral.com' for sandbox
        'redirectUrl' => 'https://your-app.com/ringcentral/callback',
        'tokenRefreshCallback' => function($tokens) {
            // Save new tokens to your storage
            Yii::$app->cache->set('ringcentral_access_token', $tokens['access_token']);
            Yii::$app->cache->set('ringcentral_refresh_token', $tokens['refresh_token']);
        }
    ],
]
```

OAuth 2.0 Setup
---------------

[](#oauth-20-setup)

1. Go to RingCentral Developer Portal
2. Select your application
3. Under "Auth &amp; Security":
    - Enable "OAuth 2.0"
    - Enable "Issue refresh tokens"
    - Add your redirect URI (e.g., `https://your-app.com/ringcentral/callback`)

Implementing OAuth Flow
-----------------------

[](#implementing-oauth-flow)

1. Create a controller to handle the OAuth flow:

```
namespace app\controllers;

use Yii;
use yii\web\Controller;

class RingCentralController extends Controller
{
    /**
     * Initiates OAuth flow
     */
    public function actionAuth()
    {
        // Generate a random state for CSRF protection
        $state = Yii::$app->security->generateRandomString();
        Yii::$app->session->set('ringcentral_state', $state);

        // Get authorization URL and redirect
        $authUrl = Yii::$app->ringcentralFax->getAuthorizationUrl($state);
        return $this->redirect($authUrl);
    }

    /**
     * Handles OAuth callback
     */
    public function actionCallback()
    {
        // Verify state parameter
        $state = Yii::$app->request->get('state');
        $savedState = Yii::$app->session->get('ringcentral_state');

        if (!$state || $state !== $savedState) {
            throw new \yii\web\BadRequestHttpException('Invalid state parameter');
        }

        // Exchange authorization code for tokens
        $code = Yii::$app->request->get('code');
        try {
            $tokens = Yii::$app->ringcentralFax->handleOAuthCallback($code);

            // Tokens are automatically saved via tokenRefreshCallback
            Yii::$app->session->setFlash('success', 'Successfully connected to RingCentral');
            return $this->redirect(['site/index']);

        } catch (\Exception $e) {
            Yii::$app->session->setFlash('error', 'Failed to connect to RingCentral: ' . $e->getMessage());
            return $this->redirect(['site/index']);
        }
    }
}
```

2. Add routes in `config/web.php`:

```
'urlManager' => [
    'enablePrettyUrl' => true,
    'rules' => [
        'ringcentral/auth' => 'ring-central/auth',
        'ringcentral/callback' => 'ring-central/callback',
    ],
],
```

3. Add a link to start the OAuth flow:

```
use yii\helpers\Html;

echo Html::a('Connect RingCentral', ['ring-central/auth'], ['class' => 'btn btn-primary']);
```

Token Management
----------------

[](#token-management)

The extension handles token management automatically:

1. When tokens are first obtained via OAuth:

    - Both access and refresh tokens are saved via your `tokenRefreshCallback`
    - The tokens are used for subsequent API calls
2. When the access token expires:

    - The extension automatically uses the refresh token to get a new access token
    - Your `tokenRefreshCallback` is called with the new tokens
    - The failed request is automatically retried
3. If the refresh token expires:

    - The user will need to re-authenticate via OAuth
    - You can catch this case by checking for the 'refresh\_token\_expired' error

Usage
-----

[](#usage)

```
try {
    // Send a fax
    $result = Yii::$app->ringcentralFax->send([
        'to' => '+1234567890',
        'files' => ['/path/to/file.pdf'],
        'text' => 'Optional cover page text'
    ]);
} catch (\yii\base\Exception $e) {
    if (strpos($e->getMessage(), 'refresh_token_expired') !== false) {
        // Redirect user to re-authenticate
        return $this->redirect(['ring-central/auth']);
    }
    // Handle other errors
    Yii::error('Fax sending failed: ' . $e->getMessage());
}
```

Best Practices
--------------

[](#best-practices)

1. Store sensitive credentials securely:

```
'ringcentralFax' => [
    'class' => 'ringcentral\fax\RingCentralFax',
    'clientId' => getenv('RINGCENTRAL_CLIENT_ID'),
    'clientSecret' => getenv('RINGCENTRAL_CLIENT_SECRET'),
    'redirectUrl' => getenv('RINGCENTRAL_REDIRECT_URL'),
    'serverUrl' => getenv('RINGCENTRAL_SERVER_URL'),
],
```

2. Use environment-specific URLs:

```
'serverUrl' => YII_DEBUG
    ? 'https://platform.devtest.ringcentral.com'
    : 'https://platform.ringcentral.com',
'redirectUrl' => YII_DEBUG
    ? 'http://localhost:8080/ringcentral/callback'
    : 'https://your-app.com/ringcentral/callback',
```

3. Always implement the tokenRefreshCallback to persist new tokens:

```
'tokenRefreshCallback' => function($tokens) {
    // Save to database
    Yii::$app->db->createCommand()
        ->update('settings', [
            'access_token' => $tokens['access_token'],
            'refresh_token' => $tokens['refresh_token']
        ], ['name' => 'ringcentral'])
        ->execute();
},
```

License
-------

[](#license)

This project is licensed under the MIT License - see the LICENSE file for details.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance42

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

8

Last Release

481d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0397341c0925b342659ac19596a27090e323d84550fe149bb1342d54d46d7917?d=identicon)[jais-nikhil](/maintainers/jais-nikhil)

---

Top Contributors

[![jais-nikhil](https://avatars.githubusercontent.com/u/36066806?v=4)](https://github.com/jais-nikhil "jais-nikhil (8 commits)")

---

Tags

yii2extensionringcentralfax

### Embed Badge

![Health badge](/badges/jithvar-yii2-ringcentral/health.svg)

```
[![Health](https://phpackages.com/badges/jithvar-yii2-ringcentral/health.svg)](https://phpackages.com/packages/jithvar-yii2-ringcentral)
```

###  Alternatives

[vyants/yii2-daemon

Extension provides functionality for simple daemons creation and control

7859.0k](/packages/vyants-yii2-daemon)[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

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