Looking to hire Laravel developers? Try LaraJobs

laravel-tmdb maintained by thethunderturner

Description
A way to access TMDB from Laravel
Last update
2026/09/30 17:15 (dev-main)
License
Downloads
2

Comments
comments powered by Disqus

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.