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 Edmunds Laravel Package

dansup/laravel-edmunds

Deprecated Laravel package for the Edmunds API. Note: Edmunds has retired its open APIs, so this package is no longer maintained or usable for new integrations.

View on GitHub
Deep Wiki
Context7

Getting Started

Install via Composer:

composer require vendor/package-name

Register the package service provider in config/app.php (if not auto-discovered). The package now defaults to disabling Guzzle's http_errors flag (set to false), simplifying error handling by requiring manual HTTP status checks (e.g., response->getStatusCode() === 200). Test with a basic HTTP request:

use Vendor\Package\Facades\Client;

$response = Client::get('https://api.example.com/data');
if ($response->getStatusCode() !== 200) {
    // Handle non-2xx responses explicitly
    throw new \RuntimeException('API request failed');
}

Implementation Patterns

Error Handling Workflow

  1. Disable http_errors: The package now defaults to http_errors: false, meaning Guzzle will not throw exceptions for HTTP errors (e.g., 4xx/5xx). Use this to:

    • Log raw responses for debugging:
      $response = Client::post('/submit', ['data' => $payload]);
      if ($response->getStatusCode() >= 400) {
          \Log::error('API Error:', ['status' => $response->getStatusCode(), 'body' => $response->getBody()->getContents()]);
      }
      
    • Implement custom retry logic for transient failures (e.g., 503).
  2. Fallback to Exceptions (Optional): Override the default config in config/package.php:

    'guzzle' => [
        'http_errors' => true, // Revert to throwing exceptions
    ],
    

Integration with Laravel HTTP Clients

Leverage the package’s client alongside Laravel’s Http facade for consistency:

// Package client (custom config)
$response = Client::withOptions(['timeout' => 30])->get('/data');

// Laravel HTTP client (default behavior)
$response = Http::timeout(30)->get('/data');

Gotchas and Tips

Breaking Changes

  • 1.2.0+: http_errors: false is now the default. Existing code relying on Guzzle exceptions for HTTP errors will break. Update error-handling logic to check $response->getStatusCode() explicitly.

Debugging Tips

  1. Inspect Raw Responses: Use dd($response->getBody()->getContents()) to debug API payloads when http_errors is disabled.
  2. Enable Guzzle Middleware: Add middleware to log requests/responses:
    Client::withMiddleware(new \GuzzleHttp\Middleware::tap(function ($request, $next) {
        \Log::debug('Request:', ['url' => (string) $request->getUri()]);
        return $next($request)->then(function ($response) {
            \Log::debug('Response:', ['status' => $response->getStatusCode()]);
            return $response;
        });
    }));
    

Extension Points

  • Custom Error Handling: Create a macro to wrap responses:
    Client::macro('safeGet', function ($url) {
        $response = $this->get($url);
        if ($response->getStatusCode() !== 200) {
            throw new \Vendor\Package\Exceptions\ApiException($response);
        }
        return $response;
    });
    
  • Override Config Globally: Publish the config and customize:
    php artisan vendor:publish --tag=package-config
    
    Then modify config/package.php to re-enable http_errors if needed.

Performance Note

Disabling http_errors avoids exception overhead but requires manual status checks. For high-throughput APIs, consider:

$response = Client::get('/data')->getBody()->getContents(); // Skip status checks if 200 is guaranteed
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.
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony
spatie/flare-daemon-runtime