PHPackages                             rexlmanu/laravel-cache-tmdb - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. rexlmanu/laravel-cache-tmdb

ActiveLibrary[API Development](/categories/api)

rexlmanu/laravel-cache-tmdb
===========================

Interact with TMDB data in your Laravel application.

11PHP

Since Jul 9Pushed 2y agoCompare

[ Source](https://github.com/rexlManu/laravel-cache-tmdb)[ Packagist](https://packagist.org/packages/rexlmanu/laravel-cache-tmdb)[ RSS](/packages/rexlmanu-laravel-cache-tmdb/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![](.github/banner.png)](.github/banner.png)

### Please do not use this package but instead use the official one.

[](#please-do-not-use-this-package-but-instead-use-the-official-one)

Laravel TMDB
============

[](#laravel-tmdb)

[![Latest Version](https://camo.githubusercontent.com/199915bbaa0d231779d12b2a0120a8e0d6238f459761666dc61563c3462d7772/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617374726f746f6d69632f6c61726176656c2d746d64622e7376673f6c6162656c3d52656c65617365267374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/astrotomic/laravel-tmdb)[![MIT License](https://camo.githubusercontent.com/332f0942904080e2191ac19911656f11139abb77014579e442db2908e5bc052b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f417374726f746f6d69632f6c61726176656c2d746d64622e7376673f6c6162656c3d4c6963656e736526636f6c6f723d626c7565267374796c653d666f722d7468652d6261646765)](https://github.com/Astrotomic/laravel-tmdb/blob/master/LICENSE)[![Offset Earth](https://camo.githubusercontent.com/d204555ebe1fb0ae82d10c97b4f4ffc2dfdd2ba1489f98be7f7e8708333a0466/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54726565776172652d2546302539462538432542332d677265656e3f7374796c653d666f722d7468652d6261646765)](https://forest.astrotomic.info)[![Larabelles](https://camo.githubusercontent.com/a2c8d5126ddd8c5ddc627176d1d2e0568f8399b50038e71fd7f774c3e24dbe4b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726162656c6c65732d2546302539462541362538342d6c6967687470696e6b3f7374796c653d666f722d7468652d6261646765)](https://larabelles.com)

[![GitHub Workflow Status](https://camo.githubusercontent.com/d661a41bd6ab2a734638d350c2e85acba34f9f3471bc4b21875bf9698bce7d2e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f417374726f746f6d69632f6c61726176656c2d746d64622f706573743f7374796c653d666c61742d737175617265266c6f676f436f6c6f723d7768697465266c6f676f3d676974687562266c6162656c3d5465737473)](https://github.com/Astrotomic/laravel-tmdb/actions?query=workflow%3Apest)[![GitHub Workflow Status](https://camo.githubusercontent.com/d0eb11357aa387cfabc9b9c49fc3f47cd75075cc288cf6fef3bc5988f9e67275/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f417374726f746f6d69632f6c61726176656c2d746d64622f70687063733f7374796c653d666c61742d737175617265266c6f676f436f6c6f723d7768697465266c6f676f3d676974687562266c6162656c3d5048502b4353)](https://github.com/Astrotomic/laravel-tmdb/actions?query=workflow%3Aphpcs)[![Total Downloads](https://camo.githubusercontent.com/2bac865502b5d5a3bee560ae2baa1f8ef1133307ab2cc1866bfdaa42a5b8dfb6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617374726f746f6d69632f6c61726176656c2d746d64622e7376673f6c6162656c3d446f776e6c6f616473267374796c653d666c61742d737175617265)](https://packagist.org/packages/astrotomic/laravel-tmdb)

Installation
------------

[](#installation)

```
composer require astrotomic/laravel-tmdb
php artisan vendor:publish --tag=tmdb-migrations
```

Configuration
-------------

[](#configuration)

Add your [TMDB API v4 Token](https://www.themoviedb.org/settings/api) to the `config/services.php` file.

**config/services.php**

```
return [
    // ...

    'tmdb' => [
        'token' => env('TMDB_TOKEN'),
    ],

    // ...
];
```

After that you can configure your language and region to be used by the package for some of the API requests. By default we use `app()->getLocale()` for the language and a hardcoded `US` region. It's recommended to call this in your `AppServiceProvider` but you can call the methods from everywhere in your codecase.

```
use Astrotomic\Tmdb\Facades\Tmdb;

Tmdb::useLanguage('de');
Tmdb::useRegion('DE');
```

Usage
-----

[](#usage)

### Models

[](#models)

The easiest and most feature complete way to use the package are the provided models. They come with custom query builders which do API calls if the requested model isn't found in your local database. This only applies to the `find()` and sometimes the `all()` methods. So if you only want to query your database, you can do so by using `whereKey()->first()` for example.

```
use Astrotomic\Tmdb\Models\Movie;

Movie::find(335983);
Movie::findMany([335983, 575788]);
Movie::findOrFail(335983);
```

It's recommended to prepare two "static" models to save future calls by calling their `all()` method once. This will do one HTTP call per model and save multiple HTTP calls in the future.

```
use Astrotomic\Tmdb\Models\MovieGenre;
use Astrotomic\Tmdb\Models\TvGenre;
use Astrotomic\Tmdb\Models\WatchProvider;

MovieGenre::all();
TvGenre::all();
WatchProvider::all();
```

Most models use [spatie/laravel-translatable](https://github.com/spatie/laravel-translatable) with a slightly customized `translate()` method. This will automatically load a missing translation if you request it.

```
use Astrotomic\Tmdb\Models\Movie;

app()->setLocale('en');
$movie = Movie::find(335983);
$movie->translate('title', 'en'); // get title from DB
$movie->translate('title', 'de'); // get and persist title from API
```

If you want to update the data in your database you can call the `updateFromTmdb()` method on any of the models. This should be done a console command or queue job as it will do a lot of HTTP requests and can take few minutes per movie.

```
use Astrotomic\Tmdb\Models\Movie;

Movie::eachById(static function(Movie $movie): void {
    $movie->updateFromTmdb('de', ['credits']);
});
```

#### Movie

[](#movie)

First of all you can also `find()` a movie with additional relations and they will also be queried from the API. To do so you only have to call the `with()` method on the query before you call any of the `find()` methods.

```
use Astrotomic\Tmdb\Models\Movie;

Movie::with('genres')->find(335983);
Movie::with('credits')->find(335983);
Movie::with('cast')->find(335983);
Movie::with('crew')->find(335983);
```

There are some methods that do a HTTP call every single time. And if they accept a `$limit` argument they automically call each page till the amount of IDs is found. You have to provide an explicit argument, in case you use `null` it will call **every** page. This can result in several thousands of requests - so it's more recommended to provide a serious number.

```
use Astrotomic\Tmdb\Models\Movie;

Movie::popular(20);
Movie::upcoming(20);
Movie::toprated(20);
Movie::trending(20);

Movie::findOrFail(335983)->recommendations(20);
Movie::findOrFail(335983)->similars(20);
```

You can also get all watch providers (powered by [JustWatch](https://justwatch.com)) for a given movie. These can be filtered/limited to a given region and/or type.

```
use Astrotomic\Tmdb\Models\Movie;
use Astrotomic\Tmdb\Enums\WatchProviderType;

Movie::findOrFail(335983)->watchProviders();
Movie::findOrFail(335983)->watchProviders('DE');
Movie::findOrFail(335983)->watchProviders(null, WatchProviderType::FLATRATE());
Movie::findOrFail(335983)->watchProviders('DE', WatchProviderType::FLATRATE());
```

And there are some helper methods on the movie model to easier work with some attributes.

```
use Astrotomic\Tmdb\Models\Movie;

Movie::findOrFail(335983)->runtime();
Movie::findOrFail(335983)->poster();
Movie::findOrFail(335983)->backdrop();
```

#### Person

[](#person)

The person model has the same base model as the movie and general method API.

```
use Astrotomic\Tmdb\Models\Person;

Person::with('movie_credits')->find(6384);
Person::trending(20);
Person::findOrFail(6384)->profile();
```

### Images

[](#images)

There are some helper classes to generate image URLs for you with correct aspect-ratio. Models with image path attributes have a shortcut method which returns an instance of that image class.

```
use Astrotomic\Tmdb\Models\Movie;

Movie::find(335983)->poster();
Movie::find(335983)->backdrop();
```

These image helpers will render a `` tag if you echo them in your Blade templates. In case they are casted to string they will return the image URL or a fallback one. You can also call `url()` or `fallback()` to get one or the other URL and use them however you want.

### Requests

[](#requests)

The models use OOP request classes which you can also use your own. These aren't the primary usage API but in case you need them, feel free to use.

```
use Astrotomic\Tmdb\Requests\Movie\Details;

Details::request(335983)->send()->json();
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/Astrotomic/.github/blob/master/CONTRIBUTING.md) for details. You could also be interested in [CODE OF CONDUCT](https://github.com/Astrotomic/.github/blob/master/CODE_OF_CONDUCT.md).

### Security

[](#security)

If you discover any security related issues, please check [SECURITY](https://github.com/Astrotomic/.github/blob/master/SECURITY.md) for steps to report it.

Credits
-------

[](#credits)

- [Tom Witkowski](https://github.com/Gummibeer)
- [Stefano Novelli](https://github.com/murdercode)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Treeware
--------

[](#treeware)

You're free to use this package, but if it makes it to your production environment I would highly appreciate you buying the world a tree.

It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to [plant trees](https://www.bbc.co.uk/news/science-environment-48870920). If you contribute to my forest you’ll be creating employment for local families and restoring wildlife habitats.

You can buy trees at [ecologi.com/astrotomic](https://forest.astrotomic.info)

Read more about Treeware at [treeware.earth](https://treeware.earth)

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

 Bus Factor1

Top contributor holds 71.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/32296940?v=4)[Emmanuel Lampe](/maintainers/rexlManu)[@rexlManu](https://github.com/rexlManu)

---

Top Contributors

[![Gummibeer](https://avatars.githubusercontent.com/u/6187884?v=4)](https://github.com/Gummibeer "Gummibeer (58 commits)")[![murdercode](https://avatars.githubusercontent.com/u/7630252?v=4)](https://github.com/murdercode "murdercode (22 commits)")[![rexlManu](https://avatars.githubusercontent.com/u/32296940?v=4)](https://github.com/rexlManu "rexlManu (1 commits)")

### Embed Badge

![Health badge](/badges/rexlmanu-laravel-cache-tmdb/health.svg)

```
[![Health](https://phpackages.com/badges/rexlmanu-laravel-cache-tmdb/health.svg)](https://phpackages.com/packages/rexlmanu-laravel-cache-tmdb)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
