duyplus / tmdbapi
TMDB API v3 PHP client library, updated for CI4 compatibility
Requires
- php: >=7.3
- ext-curl: *
- ext-json: *
Suggests
- codeigniter4/framework: For integration with CodeIgniter 4
This package is auto-updated.
Last update: 2025-03-14 05:52:36 UTC
README
TMDB API v3 PHP Library - wrapper to API version 3 of themoviedb.org. With the TMDB API v3 PHP Library, you can easily access information about movies, actors, reviews, genres, and many other related data. The library supports basic HTTP requests and automatically handles JSON responses, enabling you to quickly and efficiently integrate TMDB functionalities into your PHP projects with flexibility.
Installation
You can install the TMDB API via Composer:
composer require duyplus/tmdbapi
Requirements
- PHP 5.3.x or higher
- cURL
- TMDB API Key (get key from here)
Documentation
Changelog
Initialize the class
If you have a $conf array
use Duyplus\TMDBApi\TMDB; // if you have a $conf array - (See LIB_ROOT/src/Config/Default.php as an example) $tmdb = new TMDB($conf);
If you have no $conf array it uses the default conf but you need to have an API Key
use Duyplus\TMDBApi\TMDB; // if you have no $conf it uses the default config $tmdb = new TMDB(); //Insert your API Key of TMDB //Necessary if you use default conf $tmdb->setAPIKey('YOUR_API_KEY');
Movies
Search a Movie
//Title to search for $title = 'back to the future'; $movies = $tmdb->searchMovie($title); // returns an array of Movie Object foreach ($movies as $movie) { echo $movie->getTitle() . '<br>'; }
returns an array of Movie Objects.
Get a Movie
You should take a look at the Movie class Documentation and see all the info you can get from a Movie Object.
$idMovie = 11; $movie = $tmdb->getMovie($idMovie); // returns a Movie Object echo $movie->getTitle();
returns a Movie Object.
TV Shows
Search a TV Show
// Title to search for $title = 'breaking bad'; $tvShows = $tmdb->searchTVShow($title); foreach ($tvShows as $tvShow) { echo $tvShow->getName() . '<br>'; }
returns an array of TVShow Objects.
Get a TVShow
You should take a look at the TVShow class Documentation and see all the info you can get from a TVShow Object.
$idTVShow = 1396; $tvShow = $tmdb->getTVShow($idTVShow); // returns a TVShow Object echo $tvShow->getName();
returns a TVShow Object.
Get a TVShow's Season
You should take a look at the Season class Documentation and see all the info you can get from a Season Object.
$idTVShow = 1396; $numSeason = 2; $season = $tmdb->getSeason($idTVShow, $numSeason); // returns a Season Object echo $season->getName();
returns a Season Object.
Get a TVShow's Episode
You should take a look at the Episode class Documentation and see all the info you can get from a Episode Object.
$idTVShow = 1396; $numSeason = 2; $numEpisode = 8; $episode = $tmdb->getEpisode($idTVShow, $numSeason, $numEpisode); // returns a Episode Object echo $episode->getName();
returns a Episode Object.
Persons
Search a Person
// Name to search for $name = 'Johnny'; $persons = $tmdb->searchPerson($name); foreach ($persons as $person) { echo $person->getName() . '<br>'; }
returns an array of Person Objects.
Get a Person
You should take a look at the Person class Documentation and see all the info you can get from a Person Object.
$idPerson = 85; $person = $tmdb->getPerson($idPerson); // returns a Person Object echo $person->getName();
returns a Person Object.
Get Person's Roles
You should take a look at the Role class Documentation and see all the info you can get from a Role Object.
$movieRoles = $person->getMovieRoles(); foreach ($movieRoles as $movieRole) { echo $movieRole->getCharacter() . ' in ' . $movieRole->getMovieTitle() . '<br>'; }
returns an array of MovieRole Objects.
$tvShowRoles = $person->getTVShow(); foreach ($tvShowRoles as $tvShowRole) { echo $tvShowRole->getCharacter() . ' in ' . $tvShowRole->getMovieName() . '<br>'; }
returns an array of TVShowRole Objects.
Collections
Search a Collection
// Name to search for $name = 'the hobbit'; $collections = $tmdb->searchCollection($name); foreach ($collections as $collection) { echo $collection->getName() . '<br>'; }
returns an array of Collection Objects.
Get a Collection
You should take a look at the Collection class Documentation and see all the info you can get from a Collection Object.
$idCollection = 121938; $collection = $tmdb->getCollection($idCollection); // returns a Collection Object echo $collection->getName();
returns a Collection Object.
Companies
Search a Company
// Name to search for $name = 'Sony'; $companies = $tmdb->searchCompany($name); foreach ($companies as $company) { echo $company->getName() . '<br>'; }
returns an array of Company Objects.
Get a Company
You should take a look at the Company class Documentation and see all the info you can get from a Company Object.
$idCompany = 34; $company = $tmdb->getCompany($idCompany); // returns a Company Object echo $company->getName();
returns a Company Object.
Credits
@author Pixelead0 also on Github
@author Deso85 also on Github
Forked from a similar project by Burhan Ibrahimi
License
This project is licensed under the MIT License. See the LICENSE file for details.