thethunderturner / laravel-tmdb
A way to access TMDB from Laravel
Fund package maintenance!
Requires
- php: ^8.3
- guzzlehttp/guzzle: ^7.8|^8.0
- guzzlehttp/psr7: ^2.9|^3.0
- illuminate/support: ^12.0||^13.0
- php-tmdb/api: ^4.1
- symfony/event-dispatcher: ^7.0|^8.0
Requires (Dev)
- larastan/larastan: ^3.9
- laravel/pao: ^1.0
- laravel/pint: ^1.29
- orchestra/testbench: ^10.0||^11.0
- pestphp/pest: ^4.6||^5.0
- pestphp/pest-plugin-laravel: ^4.1||^5.0
- pestphp/pest-plugin-type-coverage: ^4.0||^5.0
- phpstan/extension-installer: ^1.4
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Laravel TMDB
Laravel integration for php-tmdb/api.
Installation
You can install the package via Composer:
composer require thethunderturner/laravel-tmdb
Set either credential in your application's .env file:
TMDB_API_KEY=your-api-key # Or use a TMDB API read access token: TMDB_BEARER_TOKEN=your-read-access-token
When both are set, the bearer token takes precedence. The client is created when first resolved, and requires one of these credentials.
You may publish the package configuration:
php artisan vendor:publish --tag="laravel-tmdb"
Or, you may publish each resource individually:
Publishing the Configuration File
php artisan vendor:publish --tag="laravel-tmdb-config"
Usage
The service provider is discovered automatically. Inject the upstream client wherever you need TMDB data:
use Tmdb\Client; final class MovieController { public function show(Client $tmdb, int $id): array { return $tmdb->getMoviesApi()->getMovie($id); } }
You can also call app(\Tmdb\Client::class) or use the LaravelTmdb\LaravelTmdb\LaravelTmdb facade. The package registers the request listeners needed by php-tmdb/api and resolves one shared client per Laravel application. To replace its PSR-18 HTTP transport, bind Psr\Http\Client\ClientInterface before resolving the TMDB client.
The package's tests use an in memory HTTP response, so composer test:unit needs no TMDB credentials or network access. API calls and response models remain the responsibility of php-tmdb/api.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Thank you for considering contributing to Laravel TMDB! Please review our contributing guide to get started.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
Laravel TMDB is open-sourced software licensed under the MIT license.