Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

joslmt/tmdb-laravel-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Movie Database Laravel Wrapper

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.

Steps to installation 📝

It's necessary to be register in The Movie Database and get a valid api key, it just take a moment.

Package Locally Development ℹ️

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 = ""

From Packagist ℹ️

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.

How to use it ❓

👉 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'
);

Testing ✔️

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

testingWrapper