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

Api Laravel Package

php-tmdb/api

PHP client for The Movie Database (TMDb) API. Search movies, TV shows, people, and collections, fetch details, images, credits, and more via a clean object-oriented wrapper. Useful for Laravel or any PHP app needing TMDb data.

View on GitHub
Deep Wiki
Context7

PHP wrapper for TMDB (TheMovieDatabase) API v3. Supports two types of approaches, one modelled with repositories, models and factories. And the other by simple array access to RAW data from The Movie Database.

Frequently asked questions about Api
Does php-tmdb/api support Laravel 10 and PHP 8.2+? If not, what breaking changes might I encounter?
The package’s last release predates Laravel 10 and PHP 8.2, so you may face issues with named arguments, constructor property promotion, or Laravel’s updated HTTP client. Test thoroughly or fork the package to backport fixes for compatibility. Check for deprecations in Laravel’s `Http` facade or Guzzle 7+ changes.
How do I integrate this package into Laravel’s service container for dependency injection?
Manually bind the TMDb client in a service provider using `app()->bind()` or `app()->singleton()`. Example: `app()->bind(TmdbClient::class, fn() => new TmdbClient(config('tmdb.api_key')));`. Store your API key in `.env` and load it via Laravel’s config system for security.
Can I cache TMDb API responses using Laravel’s cache drivers (Redis, file, etc.)?
Yes, but you’ll need to implement caching manually since the package lacks built-in Laravel cache support. Use `Cache::remember()` or `Cache::tags()` to store responses, e.g., `Cache::remember('tmdb:movie:123', now()->addHours(1), fn() => $client->getMovie(123));`. Tag caches for invalidation when data updates.
How does pagination work with Laravel’s LengthAwarePaginator or CursorPaginator?
The package supports pagination via query parameters (e.g., `?page=2`), but you’ll need to manually convert responses into Laravel paginators. For `LengthAwarePaginator`, use the `total_pages` and `total_results` fields from the API. For `CursorPaginator`, implement cursor-based logic using the API’s `page` and `results` arrays.
Is there a way to handle TMDb API rate limits using Laravel queues or middleware?
Yes, dispatch background jobs (e.g., `FetchTmdbDataJob`) to avoid rate limits. Use Laravel’s `queue` facade to delay requests and implement retry logic with `retryAfter()` in exceptions. Alternatively, add middleware like `ThrottleRequests` to monitor API call frequency globally.
Can I use this package with Laravel Scout for search-as-you-type functionality?
Not natively, but you can extend the package to integrate with Scout. Fetch TMDb search results via the client, then index them in Scout’s search engine (e.g., Algolia, Meilisearch). Trigger Scout imports via events or scheduled jobs after fetching data.
How do I securely manage my TMDb API key in Laravel?
Store the API key in your `.env` file (e.g., `TMDb_API_KEY=your_key_here`) and load it in `config/tmdb.php` using `env('TMDb_API_KEY')`. Avoid hardcoding keys in the client or version control. For added security, use Laravel’s `Vault` or encrypted config for sensitive keys.
Are there alternatives to php-tmdb/api for Laravel that are actively maintained?
Consider `spatie/laravel-tmdb` (if available) or `guzzlehttp/guzzle` with custom Laravel wrappers for more control. Alternatively, use `php-tmdb/api` as a base and extend it for Laravel-specific features. Evaluate maintenance by checking GitHub activity or open issues for critical bugs.
How can I test this package in a Laravel application before production use?
Mock the HTTP client (e.g., using Laravel’s `Http::fake()`) to test responses without hitting TMDb’s API. Write unit tests for critical methods like `getMovie()`, `searchMovies()`, and pagination. For integration tests, use `Http::fake()` with predefined responses to simulate API calls.
Does the package support async image processing or CDN integration for TMDb images?
The package provides base URLs for images, but you’ll need to extend it for async processing. Use Laravel’s `queue` facade to dispatch jobs that download and optimize images (e.g., with Intervention Image). Store processed images in Laravel’s `storage/app/public` or a CDN like Cloudinary.
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky