asanak/laravel-web-call-client
Laravel package for Asanak WebCall REST API: upload voice files, place voice or OTP calls, check call status, and get credit. Configure via .env, auto-registers service provider/facade, and optionally logs requests/responses to Laravel logs.
ApiService classes), this package can encapsulate API calls cleanly, promoting separation of concerns.Events, Listeners).Guzzle or HttpClient.WebCallClientInterface) simplify unit testing, but integration tests may require stubbing external APIs.guzzlehttp/guzzle if used elsewhere).Guzzle or Laravel’s HttpClient for critical paths.HttpClient or Guzzle?spatie/laravel-http-client, php-http/client) been considered? What’s the trade-off?config/api.php), and event system.HttpClient, but can be swapped (e.g., for testing with MockHttpClient).Redis, database) and Eloquent.WebCallClient facade or service binding.// Before
$response = Http::get('https://api.example.com/data');
// After
$client = app(WebCallClient::class)->setEndpoint('example');
$response = $client->get('/data');
WebCallClient mocks (use Mockery or PHPUnit).TrustProxies), ensure the package respects it.dispatchSync()), verify the package handles Laravel’s queue system.cache()->remember()).composer require asanak/laravel-web-call-client
php artisan vendor:publish --tag="web-call-client-config"
config/api.php:
'endpoints' => [
'example' => [
'base_url' => 'https://api.example.com',
'timeout' => 30,
],
],
$this->app->bind(WebCallClient::class, function ($app) {
return new WebCallClient($app['config']['api.endpoints.example']);
});
WebCallClient into services or use the facade:
use Asanak\WebCallClient\Facades\WebCallClient;
$data = WebCallClient::get('/data')->json();
try-catch:
try {
$response = $client->post('/data', ['key' => 'value']);
} catch (WebCallException $e) {
Log::error($e->getMessage());
throw new \RuntimeException('API failed', 0, $e);
}
config/api.php) reduce maintenance overhead but require discipline to avoid hardcoded endpoints.tap() for debugging:
$response = $client->get('/data')->tap(function ($response) {
Log::debug('Raw response:', $response->toArray());
});
HttpClient with connection pooling.Guzzle handlers.throttle middleware or use the package’s built-in retry logic.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Package Abandonment | Broken dependencies, security risks | Fork the repo or migrate to spatie/laravel-http-client if needed. |
| API Downtime | App crashes or degraded UX | Implement circuit breakers (e.g., spatie/fractal) or fallback caches. |
| Rate Limiting | Throttled requests | Use exponential backoff (package may |
How can I help you explore Laravel packages today?