Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chiiya/laravel-tmdb
Laravel package for using the TMDB API
https://github.com/chiiya/laravel-tmdb
Last synced: 5 days ago
JSON representation
Laravel package for using the TMDB API
- Host: GitHub
- URL: https://github.com/chiiya/laravel-tmdb
- Owner: chiiya
- License: mit
- Created: 2022-06-16T12:49:33.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-01T13:01:56.000Z (6 months ago)
- Last Synced: 2024-10-06T02:41:27.790Z (about 1 month ago)
- Language: PHP
- Size: 39.1 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# Laravel TMDB
[![Latest Version on Packagist](https://img.shields.io/packagist/v/chiiya/laravel-tmdb.svg?style=flat-square)](https://packagist.org/packages/chiiya/laravel-tmdb)
[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/chiiya/laravel-tmdb/lint?label=code%20style)](https://github.com/chiiya/laravel-tmdb/actions?query=workflow%3Alint+branch%3Amaster)
[![Total Downloads](https://img.shields.io/packagist/dt/chiiya/laravel-tmdb.svg?style=flat-square)](https://packagist.org/packages/chiiya/laravel-tmdb)Laravel package for using the TMDB API.
## Installation
You can install the package via composer:
```bash
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):```bash
TMDB_API_TOKEN="eyJh..."
```## Usage
This package is a thin wrapper around [chiiya/tmdb-php](https://github.com/chiiya/tmdb-php), that allows you to directly
inject the repositories in your application:```php
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](https://github.com/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](https://github.com/chiiya/tmdb-php/tree/master/tests/responses).## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.