devmachine/guzzle-rottentomatoes-client
Lightweight PHP client for the Rotten Tomatoes API built on Guzzle 4. Create a client with your API key and call endpoints like movies search (e.g., query by title) to get structured movie data (ratings, release dates, posters, cast).
Pros:
Cons:
Laravel Compatibility:
illuminate/support compatibility)..env or config files (e.g., config/services.php).Key Dependencies:
429 Too Many Requests).spatie/rottentomatoes-api)?Laravel Integration Points:
config/services.php.
$this->app->singleton(RottenTomatoesClient::class, function ($app) {
return RottenTomatoesClient::factory(config('services.rottentomatoes.key'));
});
RottenTomatoes facade for cleaner syntax (e.g., RottenTomatoes::movies()).ApiResource for JSON:API or Eloquent-like hydration.Cache::remember) to store frequent API calls (e.g., movie details).Guzzle Compatibility:
guzzlehttp/guzzle:^4.0 explicitly in composer.json.RottenTomatoesClient::movies()).spatie/rottentomatoes-api).movies()) and validate response format.Movie::with('reviews')).movies(), movie()).Log::debug($client->rawResponse)).RottenTomatoesException).try {
$movies = $client->movies(['q' => 'Terminator']);
} catch (RequestException $e) {
report($e);
return response()->json(['error' => 'API request failed'], 500);
}
Cache::remember('movies_terminator', now()->addMinutes(10), ...)).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Rotten Tomatoes API downtime | Missing movie data in UI | Fallback to cached data or gracefully degrade. |
| API key revoked | All client calls fail | Store keys in a secure vault (e.g., AWS Secrets Manager). |
| Guzzle 4 security vulnerability | Potential RCE or data leakage | Isolate the client in a microservice or container. |
| Rate limit exceeded | 429 Too Many Requests errors |
Implement retry logic with jitter delays. |
| API endpoint deprecated | Broken functionality | Plan for a custom client or alternative API. |
ROTTEN_TOMATOES.md with:
How can I help you explore Laravel packages today?