aluvia-connect / aluvia-php-sdk
Aluvia SDK for PHP
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/aluvia-connect/aluvia-php-sdk
Requires
- php: >=7.4
Requires (Dev)
- doctrine/instantiator: ^1.5.0
- phpunit/phpunit: ^9.5.10
This package is not auto-updated.
Last update: 2025-12-17 01:54:01 UTC
README
The official Aluvia PHP SDK, designed for managing your Aluvia connectivity credentials, retrieving usage data, and integrating mobile network access into PHP applications, backend systems, and automation workflows.
Lightweight, dependency-free, and powered by cURL.
Requirements
- PHP 7.4+
- cURL extension (enabled by default)
Installation
Via Composer
composer require aluvia-connect/aluvia-php-sdk
Manual Installation
require_once 'path/to/aluvia-php-sdk/src/index.php';
Quick Start
<?php use Aluvia\Aluvia; $sdk = new Aluvia('your-api-token'); // Get your first connectivity credential $credential = $sdk->first(); if ($credential) { echo "Connection URL: " . $credential->toUrl() . "\n"; echo "Username: " . $credential->getUsername() . "\n"; echo "Password: " . $credential->getPassword() . "\n"; } else { echo "No credentials available. Create one first.\n"; }
Usage Examples
Creating Connectivity Credentials
<?php $sdk = new Aluvia('your-api-token'); // Create a single credential $credentials = $sdk->create(1); $credential = $credentials[0]; echo "Created: " . $credential->toUrl() . "\n"; // Create multiple $list = $sdk->create(5); echo "Created " . count($list) . " credentials\n";
Managing Credentials
<?php $sdk = new Aluvia('your-api-token'); $credential = $sdk->find('user123'); if ($credential) { // Modify settings $credential->setUseSticky(true); // Save changes $credential->save(); echo "Credential updated.\n"; } else { echo "Credential not found.\n"; }
Usage Statistics
<?php $sdk = new Aluvia('your-api-token'); $credential = $sdk->first(); if ($credential) { // Current period usage $usage = $credential->getUsage(); echo "Used: " . $usage['dataUsed'] . " GB\n"; // Custom date range $weekly = $sdk->getUsage($credential->getUsername(), [ 'usageStart' => time() - (7 * 86400), 'usageEnd' => time(), ]); echo "Weekly usage: " . $weekly['dataUsed'] . " GB\n"; }
Connection URLs & Details
<?php $credential = $sdk->first(); if ($credential) { echo "HTTP: " . $credential->toUrl('http') . "\n"; echo "HTTPS: " . $credential->toUrl('https') . "\n"; print_r($credential->toArray()); }
Using with cURL
<?php $credential = $sdk->first(); if ($credential) { $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => 'https://ipconfig.io/json', CURLOPT_RETURNTRANSFER => true, CURLOPT_PROXY => $credential->getHost() . ':' . $credential->getHttpPort(), CURLOPT_PROXYUSERPWD => $credential->getUsername() . ':' . $credential->getPassword(), CURLOPT_PROXYTYPE => CURLPROXY_HTTP, ]); $response = curl_exec($ch); curl_close($ch); echo "Response: $response\n"; }
Deleting Credentials
<?php $credential = $sdk->find('user123'); if ($credential) { $credential->delete(); echo "Credential deleted.\n"; } $sdk->delete('anotherUser');
Error Handling
<?php use Aluvia\Exceptions\AuthenticationException; use Aluvia\Exceptions\ValidationException; use Aluvia\Exceptions\NetworkException; use Aluvia\Exceptions\ApiException; use Aluvia\Exceptions\RateLimitException; try { $credential = $sdk->first(); } catch (AuthenticationException $e) { echo "Auth error: " . $e->getMessage(); } catch (RateLimitException $e) { echo "Rate limited. Retry in " . $e->getRetryAfter() . "s"; } catch (NetworkException $e) { echo "Network issue: " . $e->getMessage(); } catch (ApiException $e) { echo "API error: " . $e->getMessage(); } catch (ValidationException $e) { echo "Invalid request: " . $e->getMessage(); }
API Reference
Aluvia Class
Constructor
new Aluvia(string $token)
Methods
| Method | Description |
|---|---|
first(): ?Proxy |
Get the most recent connectivity credential |
find(string $username): ?Proxy |
Find a credential |
create(int $count = 1): Proxy[] |
Create credentials |
update(string $username, array $options): void |
Update credential settings |
delete(string $username): void |
Delete credential |
all(): Proxy[] |
List all loaded credentials |
getUsage(string $username, array $options = []): array |
Usage analytics |
Proxy Class (Connectivity Credential)
Properties & Accessors
getUsername(): stringgetPassword(): stringgetHost(): stringgetHttpPort(): intgetHttpsPort(): intgetUseSticky(): boolsetUseSticky(bool $value)
Methods
toUrl(string $protocol = 'http'): stringsave(): selfdelete(): voidgetUsage(array $options = []): arraytoArray(): array
License
MIT License
Support
For questions or support: support@aluvia.io