Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Web Call Client Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require asanak/laravel-web-call-client
    

    Publish the config file (if needed):

    php artisan vendor:publish --provider="Asanak\WebCallClient\WebCallClientServiceProvider"
    
  2. Configuration Edit config/web-call-client.php to define your API endpoints and default headers:

    'endpoints' => [
        'default' => [
            'url' => 'https://api.example.com',
            'headers' => [
                'Accept' => 'application/json',
                'Authorization' => 'Bearer YOUR_TOKEN',
            ],
        ],
    ],
    
  3. First API Call Use the facade to make a simple GET request:

    use Asanak\WebCallClient\Facades\WebCallClient;
    
    $response = WebCallClient::get('/users');
    $data = $response->json();
    
  4. Quick Reporting Log a response for debugging:

    $response = WebCallClient::post('/report', ['data' => 'test']);
    $response->report(); // Logs full request/response to storage/logs/web-call-client.log
    

Implementation Patterns

Core Workflows

  1. Structured Requests Use named endpoints for clarity:

    $response = WebCallClient::endpoint('default')->get('/users');
    
  2. Request/Response Chaining Chain methods for fluent API calls:

    $response = WebCallClient::get('/users')
        ->withHeaders(['X-Custom-Header' => 'value'])
        ->asJson();
    
  3. Dynamic Endpoints Override endpoints per request:

    $response = WebCallClient::endpoint([
        'url' => 'https://custom-api.com',
        'headers' => ['Authorization' => 'Bearer DYNAMIC_TOKEN'],
    ])->get('/data');
    
  4. Error Handling Use exceptions for robust error handling:

    try {
        $response = WebCallClient::post('/create', ['data' => 'test']);
    } catch (\Asanak\WebCallClient\Exceptions\WebCallException $e) {
        // Handle error (e.g., log, notify user)
        report($e);
    }
    

Integration Tips

  • Laravel HTTP Client Bridge Leverage Laravel’s built-in HTTP client for advanced features:

    $response = WebCallClient::get('/users')
        ->withHttpClient(app(\Illuminate\Http\Client\PendingRequest::class));
    
  • Middleware Integration Attach middleware to requests:

    $response = WebCallClient::get('/users')
        ->withMiddleware(new \Asanak\WebCallClient\Middleware\LogRequest);
    
  • Testing Mock responses in tests:

    $mock = Mockery::mock(\Asanak\WebCallClient\Contracts\Response::class);
    $mock->shouldReceive('json')->andReturn(['test' => 'data']);
    
    $this->app->instance(\Asanak\WebCallClient\Contracts\Response::class, $mock);
    

Gotchas and Tips

Pitfalls

  1. Header Overrides Headers defined in the config are merged with per-request headers. Unexpected behavior may occur if not explicit:

    // Overrides all headers for this request
    $response = WebCallClient::get('/users')->withHeaders(['Accept' => 'text/plain']);
    
  2. Response Parsing Always check response->successful() before parsing JSON to avoid exceptions:

    if ($response->successful()) {
        $data = $response->json();
    }
    
  3. Rate Limiting The package doesn’t handle rate limiting by default. Implement middleware or use Laravel’s retry method:

    $response = WebCallClient::get('/users')->retry(3, 100);
    
  4. Logging Overhead Frequent report() calls may bloat logs. Use sparingly in production.

Debugging Tips

  • Enable Verbose Logging Set WEB_CALL_CLIENT_LOG_VERBOSE to true in .env for detailed logs.

  • Inspect Raw Response Use response->raw() to debug unexpected formats:

    $raw = $response->raw();
    
  • Check for Deprecated Methods Monitor deprecation notices in logs for breaking changes.

Extension Points

  1. Custom Responses Extend the Response class to add domain-specific methods:

    class CustomResponse extends \Asanak\WebCallClient\Response {
        public function getUserId() {
            return $this->json()['id'] ?? null;
        }
    }
    
  2. Add Middleware Register custom middleware in config/web-call-client.php:

    'middleware' => [
        \App\Middleware\CustomAuth::class,
    ],
    
  3. Event Listeners Listen for request/response events:

    \Asanak\WebCallClient\Events\BeforeRequest::class => [
        \App\Listeners\LogBeforeRequest::class,
    ],
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle