chiiya / laravel-tmdb
Laravel SDK for the TMDB API
Fund package maintenance!
chiiya
Requires
- php: ^8.1
- chiiya/tmdb-php: ^0.2
- illuminate/contracts: ^9.0|^10.0|^11.0
- spatie/laravel-package-tools: ^1.11
Requires (Dev)
- chiiya/laravel-code-style: ^1.7
- nunomaduro/collision: ^6.1
- orchestra/testbench: ^7.1
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-08-31 00:30:04 UTC
README
Laravel package for using the TMDB API.
Installation
You can install the package via composer:
composer require chiiya/laravel-tmdb
Next, configure your TMDB API token in your .env file. This should be your API Read Access Token (v4 auth):
TMDB_API_TOKEN="eyJh..."
Usage
This package is a thin wrapper around chiiya/tmdb-php, that allows you to directly inject the repositories in your application:
use Chiiya\Tmdb\Repositories\MovieRepository; use Chiiya\Tmdb\Query\AppendToResponse; class TmdbService { public function __construct( private MovieRepository $movies, ) public function handle(): void { $this->movies->getMovie(550); $this->movies->getPopular(); $movie = $this->movies->getMovie(550, [ new AppendToResponse([ AppendToResponse::IMAGES, AppendToResponse::WATCH_PROVIDERS, ]), ]); $movie->watch_providers['US']->flatrate[0]->provider_name; } }
For documentation on method signatures, check out chiiya/tmdb-php.
Testing
Since this package uses the Laravel HTTP Client under the hood to perform API requests,
you may simply call Http::fake()
to fake responses in your tests. For mocking specific responses,
check out the example responses.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.