Looking to hire Laravel developers? Try LaraJobs

tmdb-laravel-wrapper maintained by josmlt

Description
A Laravel wrapper for The Movie Database API
Author
Last update
2021/08/11 15:43 (dev-master)
License
Links
Downloads
33

Comments
comments powered by Disqus

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 :memo:

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

Package Locally Development :information_source:

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 :information_source:

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 :question:

:point_right: Get top movies or tv shows.

\TMDB::getTop('tv', ['page' => 2]);

:point_right: 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);

:point_right: 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'));

:point_right: 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 :heavy_check_mark:

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