This is a package develop with Laravel 8. It's a Laravel api wrapper to get info about movies, tv shows and more using TMDB Api and Laravel Facades.
It's necessary to be register in The Movie Database and get a valid api key, it just take a moment.
We need to create a folder and within it we'll create a Laravel project and clone the repository. Structure similar to this :
-- foo
-- laravel_project
-- package_laravel
After that, open composer.json
file in our main Laravel project, add :
"require": {
[. . .]
"josmlt/tmdb-laravel-wrapper": "dev-master",
}
"repositories": [
{
"type": "path",
"url": "../tmdb-wrapper"
}
],
Now require the package to the project, execute :
composer require josmlt/tmdb-laravel-wrapper
Then execute, it will publish the config file :
php artisan vendor:publish --tag=tmdb
Finally we have two options, first we could have a default value of TMDB_KEY, within config/tmdb.php
or as well we can add in our .env
a new environment variable like TMDB_KEY = ""
composer require josmlt/tmdb-laravel-wrapper
Now we need to publish the config file :
php artisan vendor:publish --tag=tmdb
Finally we move into :
config/tmdb.php
And add our api key from The Movie Database, or alternative you can create a new environment variable named like TMDB_KEY
.
👉 Get top movies or tv shows.
\TMDB::getTop('tv', ['page' => 2]);
👉 Get more details about a specific movie, tv shows or an actor, set the last parameter to true and get available videos.
\TMDB::getDetails('movie', 3333, true);
👉 To search movies, tv shows and people use search method or searchAsync to do an asyncronus search, usefull when you have to send multiple request.
\TMDB::searchAsync('person', 'tom'));
👉 Discover new movies with the follow method, it's also provided with many filter and sorting options, an example of use.
\TMDB::movieDiscover(
'without_genres' => 28,
'year' => '2020'
);
This package provides tests to get more confident using the package and check if it's possible to add a new feature without broke nothing valuable.
To execute tests :
vendor/bin/phpunit tests/Unit/TMDBTest.php