PHPackages                             avraapi/apix-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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. avraapi/apix-php-sdk

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

avraapi/apix-php-sdk
====================

Official PHP SDK for the APIX (AvraAPI) enterprise API gateway. Zero Laravel dependencies — works in any PHP 8.2+ project.

1.0.0(3mo ago)11↑2900%MITPHPPHP ^8.2

Since Apr 2Pushed 1mo agoCompare

[ Source](https://github.com/avraapi/php-sdk)[ Packagist](https://packagist.org/packages/avraapi/apix-php-sdk)[ RSS](/packages/avraapi-apix-php-sdk/feed)WikiDiscussions main Synced 3mo ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

AvraAPI PHP SDK
===============

[](#avraapi-php-sdk)

Official PHP SDK for the [AvraAPI (APIX)](https://avraapi.com) enterprise API gateway.

Zero Laravel dependencies — works in any PHP 8.2+ project.

> **Full documentation &amp; guides:**

```
composer require avraapi/php-sdk
```

Quick Start
-----------

[](#quick-start)

```
use Avraapi\Apix\ApixClient;

$apix = new ApixClient([
    'apiKey'    => 'your-api-key',
    'apiSecret' => 'your-api-secret',
    'env'       => 'dev', // 'dev' or 'prod'
]);
```

Services
--------

[](#services)

ServiceAccessorEndpointsLocation`$apix->location()`IP geolocation lookupsSMS`$apix->sms()`Single, bulk-same, bulk-different, balanceUtilities`$apix->utilities()`QR codes, barcodes, **PDF generation**Security`$apix->security()`VPN &amp; Proxy Shield, Burner Email DetectionCurrency`$apix->currency()`Currency codes, live rates, pair rates, conversion---

PDF Generation
--------------

[](#pdf-generation)

### Basic HTML to PDF

[](#basic-html-to-pdf)

```
$html = 'Invoice #001Total: $99.00';
$response = $apix->utilities()->generatePdf($html);
$response->saveAs('/tmp/invoice.pdf');
```

### Landscape with Custom Margins

[](#landscape-with-custom-margins)

```
$response = $apix->utilities()->generatePdf(
    html:        $html,
    pageSize:    'A4',
    orientation: 'landscape',
    margins:     ['top' => 20, 'right' => 25, 'bottom' => 20, 'left' => 25],
);
$response->saveAs('/tmp/landscape.pdf');
```

### Base64 JSON Response

[](#base64-json-response)

```
$response = $apix->utilities()->generatePdf($html, responseType: 'base64');
$base64Pdf = $response->data['data'];
file_put_contents('/tmp/invoice.pdf', base64_decode($base64Pdf));
```

---

Generating PDFs from Complex Templates (Base64 Mode)
----------------------------------------------------

[](#generating-pdfs-from-complex-templates-base64-mode)

When your HTML contains quotes, newlines, inline CSS, or special characters, JSON escaping can cause issues. **Base64 mode** solves this by encoding the HTML before transport.

### Option A: Use the `generatePdfFromBase64()` Helper (Recommended)

[](#option-a-use-the-generatepdffrombase64-helper-recommended)

The helper accepts **raw HTML** and encodes it automatically:

```
// Load a complex template from disk
$html = file_get_contents('/templates/invoice.html');

// The SDK Base64-encodes internally — no manual encoding needed
$response = $apix->utilities()->generatePdfFromBase64($html);
$response->saveAs('/tmp/invoice.pdf');

// With full options:
$response = $apix->utilities()->generatePdfFromBase64(
    html:        $html,
    responseType: 'binary',
    pageSize:    'Letter',
    orientation: 'landscape',
    margins:     ['top' => 15, 'right' => 20, 'bottom' => 15, 'left' => 20],
    privacyMode: true,
);
$response->saveAs('/tmp/invoice.pdf');
```

### Option B: Manual Base64 Encoding

[](#option-b-manual-base64-encoding)

If you need full control, encode the HTML yourself and set `isBase64: true`:

```
$html = file_get_contents('/templates/invoice.html');

$response = $apix->utilities()->generatePdf(
    html:     base64_encode($html),
    isBase64: true,
);
$response->saveAs('/tmp/invoice.pdf');
```

### How It Works

[](#how-it-works)

1. The SDK sends the Base64 string in the `html` field with `is_base64: true`.
2. The server decodes the Base64 content before validation and rendering.
3. The **512 KB size limit** applies to the **decoded** HTML, not the encoded payload.

---

Saving Files to Disk
--------------------

[](#saving-files-to-disk)

Both `BinaryResponse` and the base64 JSON response support saving to disk:

```
// Binary response — use saveAs() directly:
$response = $apix->utilities()->generatePdf($html);
$savedPath = $response->saveAs('/tmp/invoice.pdf');
echo "Saved to: {$savedPath}";

// BinaryResponse also provides:
$response->body;         // Raw binary string
$response->contentType;  // 'application/pdf'
$response->size;         // Size in bytes
$response->isPdf();      // true
$response->toDataUri();  // 'data:application/pdf;base64,...'

// Base64 JSON response — decode and write manually:
$response = $apix->utilities()->generatePdf($html, responseType: 'base64');
file_put_contents('/tmp/invoice.pdf', base64_decode($response->data['data']));
```

---

VPN &amp; Proxy Shield
----------------------

[](#vpn--proxy-shield)

Detect VPNs, proxies, Tor exit nodes, iCloud Private Relay, and hosting/datacenter IPs.

```
$result = $apix->security()->checkVpn('8.8.8.8');

echo $result->data['ip_address'];    // '8.8.8.8'
echo $result->data['is_vpn'];        // false
echo $result->data['is_proxy'];      // false
echo $result->data['is_tor'];        // false
echo $result->data['is_relay'];      // false
echo $result->data['is_hosting'];    // false
echo $result->data['country_code'];  // 'US'
echo $result->data['city'];          // 'Mountain View'
echo $result->data['asn'];           // '15169'
echo $result->data['network_name'];  // 'Google LLC'
echo $result->data['provider_name']; // 'vpnapi' or 'iplocate'

// Quick threat check:
$d = $result->data;
$isThreat = $d['is_vpn'] || $d['is_proxy'] || $d['is_tor'];
```

---

Burner Email Shield
-------------------

[](#burner-email-shield)

Detect temporary and disposable email addresses using a dual-list Redis lookup (7,000+ domains).

```
$result = $apix->security()->checkBurnerEmail('user@mailinator.com');

echo $result->data['email'];             // 'user@mailinator.com'
echo $result->data['domain'];            // 'mailinator.com'
echo $result->data['is_valid_syntax'];   // true
echo $result->data['is_disposable'];     // true
echo $result->data['source'];            // 'global', 'custom', or 'none'
echo $result->data['execution_time_ms']; // 0.42

// Guard a registration form:
if ($result->data['is_disposable']) {
    throw new \Exception('Disposable emails are not allowed.');
}
```

---

Multi-Currency Rates &amp; Conversion
-------------------------------------

[](#multi-currency-rates--conversion)

Free currency exchange rate API — 160+ currencies, 2-hour cached rates, zero credit cost.

### Get All Currency Codes

[](#get-all-currency-codes)

```
$result = $apix->currency()->getCodes();

echo $result->data['count']; // 161
foreach ($result->data['codes'] as $c) {
    echo "{$c['code']} — {$c['name']}\n"; // 'USD — United States Dollar'
}
```

### Get Latest Rates from a Base Currency

[](#get-latest-rates-from-a-base-currency)

```
$result = $apix->currency()->getLatestRates('USD');

echo $result->data['base'];              // 'USD'
echo $result->data['last_updated'];      // '2025-05-10T...'
echo $result->data['rates']['EUR'];      // 0.89123456
echo $result->data['rates']['LKR'];      // 298.50000000
```

### Get Pair Rate

[](#get-pair-rate)

```
$result = $apix->currency()->getPairRate('USD', 'EUR');

echo $result->data['base'];         // 'USD'
echo $result->data['target'];       // 'EUR'
echo $result->data['rate'];         // 0.89123456
echo $result->data['last_updated']; // '2025-05-10T...'
```

### Convert an Amount

[](#convert-an-amount)

```
$result = $apix->currency()->convert('USD', 'LKR', 100.00);

$d = $result->data;
echo "{$d['amount']} {$d['base']} = {$d['conversion_result']} {$d['target']}";
// "100 USD = 29850.000000 LKR"

echo $d['rate'];              // 298.50000000
echo $d['conversion_result']; // 29850.000000
echo $d['last_updated'];      // '2025-05-10T...'
```

---

Privacy Mode
------------

[](#privacy-mode)

For sensitive documents (invoices, contracts, PII), enable privacy mode to exclude HTML content from observability logs:

```
$response = $apix->utilities()->generatePdf($html, privacyMode: true);
$response->saveAs('/tmp/confidential.pdf');
```

---

Error Handling
--------------

[](#error-handling)

The SDK throws typed exceptions for all API error responses:

```
use Avraapi\Apix\Exceptions\ApixAuthenticationException;
use Avraapi\Apix\Exceptions\ApixInsufficientFundsException;
use Avraapi\Apix\Exceptions\ApixRateLimitException;
use Avraapi\Apix\Exceptions\ApixValidationException;
use Avraapi\Apix\Exceptions\ApixException;

try {
    $response = $apix->utilities()->generatePdf($html);
    $response->saveAs('/tmp/invoice.pdf');
} catch (ApixRateLimitException $e) {
    // HTTP 429 — rate limit exceeded
    echo "Rate limited. Retry after: " . $e->getMessage();
} catch (ApixInsufficientFundsException $e) {
    // HTTP 402 — wallet balance too low
    echo "Insufficient balance: " . $e->getMessage();
} catch (ApixValidationException $e) {
    // HTTP 422 — invalid input
    print_r($e->getValidationErrors());
} catch (ApixAuthenticationException $e) {
    // HTTP 401 — bad credentials
    echo "Auth failed: " . $e->getMessage();
} catch (ApixException $e) {
    // Catch-all for any other APIX error
    echo "[{$e->getErrorCode()}] {$e->getMessage()}";
}
```

---

Documentation
-------------

[](#documentation)

For full API reference, usage guides, and interactive examples, visit:

****

---

License
-------

[](#license)

MIT — [Fidex Developers (Pvt) Ltd](https://avraapi.com)

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance86

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

91d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/de7ca516dc8da568b76f57ef9de8940bf1a0211b16cb671d440d83686db73ce3?d=identicon)[avraapi](/maintainers/avraapi)

---

Top Contributors

[![fidex-profile](https://avatars.githubusercontent.com/u/219648547?v=4)](https://github.com/fidex-profile "fidex-profile (7 commits)")[![fidex-developers](https://avatars.githubusercontent.com/u/219648547?v=4)](https://github.com/fidex-developers "fidex-developers (2 commits)")[![avraapi](https://avatars.githubusercontent.com/u/269558072?v=4)](https://github.com/avraapi "avraapi (1 commits)")

---

Tags

qrpdfsdksmsbarcodeapixapi-gatewayavraapi

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/avraapi-apix-php-sdk/health.svg)

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

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[laravel/framework

The Laravel Framework.

34.8k543.8M19.9k](/packages/laravel-framework)[google/cloud-core

Google Cloud PHP shared dependency, providing functionality useful to all components.

346132.9M112](/packages/google-cloud-core)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M418](/packages/drupal-core-recommended)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)

PHPackages © 2026

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