vonage/client
Wrapper package for the Vonage PHP SDK that keeps Vonage functionality separate from the HTTP client. Requires PHP 8+. If you have conflicts with the guzzle6-adapter, use vonage/client-core plus any php-http client implementation.
vonage/client package provides a clean, object-oriented PHP SDK for interacting with Vonage’s (formerly Nexmo) APIs (e.g., SMS, Voice, Verify, Numbers). It aligns well with Laravel’s dependency injection and service container patterns, enabling seamless integration into existing Laravel applications.SmsClient, VoiceClient, VerifyClient) allows for granular adoption—teams can integrate only the required services without bloating the codebase.Illuminate\Events\Dispatcher) for reactive workflows (e.g., triggering notifications on SMS delivery)..env), aligning with Laravel’s config() and env() helpers. Example:
$client = new Vonage\Client\Credentials\Basic(
env('VONAGE_API_KEY'),
env('VONAGE_API_SECRET')
);
VonageRateLimitMiddleware) for centralized API request handling.Vonage\Client\ClientInterface) enable easy unit testing with Laravel’s Mockery or PHPUnit.composer.json (^1.0).Illuminate\Http\Middleware\VerifyCsrfToken or custom middleware can handle this.Illuminate\Queue) can process these, but race conditions may arise if not managed (e.g., retries, idempotency).guzzlehttp/guzzle) are widely used and stable.config/services.php, or managed via a secrets manager (e.g., AWS Secrets Manager)?429 Too Many Requests, 401 Unauthorized) be translated into Laravel exceptions? Custom exception classes (e.g., VonageApiException) may be needed.Log facade for debugging or compliance?throttle middleware could complement this.VonageWebhookController with route model binding may be ideal.$this->app->bind(Vonage\Client\ClientInterface::class, function ($app) {
return new Vonage\Client\Credentials\Basic(
$app['config']['services.vonage.key'],
$app['config']['services.vonage.secret']
);
});
Http facade or Guzzle (already a SDK dependency) can be used for low-level requests if SDK features are insufficient.SmsSent, CallRecorded) to decouple logic.VonageJob classes.User).Schema::create('vonage_call_records', function (Blueprint $table) {
$table->id();
$table->string('call_uuid');
$table->foreignId('user_id')->constrained();
$table->timestamps();
});
Validator to sanitize inputs before calling Vonage APIs (e.g., validate phone numbers with Vonage\Client\Validator).composer require vonage/client
.env and config/services.php.VonageService class to wrap SDK clients and handle errors.class VonageService {
protected ClientInterface $client;
public function __construct(ClientInterface $client) {
$this->client = $client;
}
public function sendSms(string $to, string $text) {
try {
$response = $this->client->sms()->send([
'to' => $to,
'from' => 'YourBrand',
'text' => $text,
]);
return $response->getMessageId();
} catch (Exception $e) {
throw new VonageApiException($e->getMessage());
}
}
}
VonageVoiceService, VonageVerifyService).Route::post('/vonage/webhook', [VonageWebhookController::class, 'handle']);
Illuminate\Cache) for rate-limited endpoints.Illuminate\Support\Facades\Retry.ClientInterface can act as a buffer for refactoring.guzzlehttp/guzzle (v7+), which is compatible with Laravel’s HTTP stack.spatie/laravel-feature-flags) for controlled rollout.composer update vonage/client and test for compatibility.^1.0) to balance stability and updates.guzzlehttp/guzzle and other SDK dependencies for security patches.composer.json scripts for automated testing post-update.config/services.php to avoid hardcodedHow can I help you explore Laravel packages today?