{"id":13545660,"url":"https://github.com/php-tmdb/laravel","last_synced_at":"2025-04-05T02:12:13.657Z","repository":{"id":20649823,"uuid":"23931866","full_name":"php-tmdb/laravel","owner":"php-tmdb","description":"Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the wtfzdotnet/php-tmdb-api library.","archived":false,"fork":false,"pushed_at":"2021-02-08T11:22:22.000Z","size":48,"stargazers_count":157,"open_issues_count":4,"forks_count":61,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-29T01:14:56.713Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/php-tmdb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-11T19:07:35.000Z","updated_at":"2024-12-05T10:45:50.000Z","dependencies_parsed_at":"2022-08-24T09:01:01.023Z","dependency_job_id":null,"html_url":"https://github.com/php-tmdb/laravel","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-tmdb%2Flaravel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-tmdb%2Flaravel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-tmdb%2Flaravel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-tmdb%2Flaravel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-tmdb","download_url":"https://codeload.github.com/php-tmdb/laravel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276189,"owners_count":20912288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T11:01:08.569Z","updated_at":"2025-04-05T02:12:13.641Z","avatar_url":"https://github.com/php-tmdb.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Laravel Package for TMDB API Wrapper\n\n[![License](https://poser.pugx.org/php-tmdb/laravel/license.png)](https://packagist.org/packages/php-tmdb/laravel)\n[![Build Status](https://travis-ci.org/php-tmdb/laravel.svg)](https://travis-ci.org/php-tmdb/laravel)\n[![Code Coverage](https://scrutinizer-ci.com/g/php-tmdb/laravel/badges/coverage.png)](https://scrutinizer-ci.com/g/php-tmdb/laravel/)\n[![PHP \u0026 HHVM](https://php-eye.com/badge/php-tmdb/laravel/tested.svg)](https://php-eye.com/package/php-tmdb/laravel)\n\nA Laravel package that provides easy access to the [php-tmdb/api](https://github.com/php-tmdb/api) TMDB (The Movie Database) API wrapper.\nThis package comes with a service provider that configures the `Tmdb\\Client` and registers it to the IoC container.\nBoth Laravel 5 and 4 are supported.\n\n[![Latest Stable Version](https://poser.pugx.org/php-tmdb/laravel/v/stable.svg)](https://packagist.org/packages/php-tmdb/laravel)\n[![Latest Unstable Version](https://poser.pugx.org/php-tmdb/laravel/v/unstable.svg)](https://packagist.org/packages/php-tmdb/laravel)\n[![Dependency Status](https://www.versioneye.com/php/php-tmdb:laravel/badge?style=flat)](https://www.versioneye.com/php/php-tmdb:laravel)\n[![Total Downloads](https://poser.pugx.org/php-tmdb/laravel/downloads.svg)](https://packagist.org/packages/php-tmdb/laravel)\n\n## Looking for maintainers\n\n*We are urgently looking for new mainteners of this library, we need someone that can steer this package in the right direction for the Laravel community, we do not currently have anybody on the `php-tmdb` team that uses laravel on a daily basis. We want the default standards to be met and unit tests to be available just to verify the part of the integration with the framework works. Send an email to `php-laravel@wtfz.net` if you are interested, or are willing to help out.*\n\n## Installation\n\nInstall Composer\n\n```\n$ curl -sS https://getcomposer.org/installer | php\n$ sudo mv composer.phar /usr/local/bin/composer\n```\n\nAdd the following to your require block in `composer.json` config\n\n```\n\"php-tmdb/laravel\": \"~1.0\"\n```\n\nor just run the following command in your project:\n\n```\ncomposer require php-tmdb/laravel\n```\n\n## Configuration\n\nAdd to your `app/config/app.php` (Laravel 4) or `config/app.php` (Laravel \u003c5.5) the service provider:\n\n```php\n'providers' =\u003e array(\n    // other service providers\n\n    'Tmdb\\Laravel\\TmdbServiceProvider',\n)\n```\n\nThen publish the configuration file:\n\n### Laravel 4\n\n```\nphp artisan config:publish php-tmdb/laravel\n```\n\n### Laravel 5\n\n```\nphp artisan vendor:publish --provider=\"Tmdb\\Laravel\\TmdbServiceProviderLaravel5\"\n```\n\nNext you can modify the generated configuration file `tmdb.php` accordingly.\n\nThat's all! Fire away!\n\n## Usage\n\nWe can choose to either use the `Tmdb` Facade, or to use dependency injection.\n\n### Facade example\n\nThe example below shows how you can use the `Tmdb` facade.\nIf you don't want to keep adding the `use Tmdb\\Laravel\\Facades\\Tmdb;` statement in your files, then you can also add the facade as an alias in `config/app.php` file.\n\n```php\nuse Tmdb\\Laravel\\Facades\\Tmdb; // optional for Laravel ≥5.5\n\nclass MoviesController {\n\n    function show($id)\n    {\n        // returns information of a movie\n        return Tmdb::getMoviesApi()-\u003egetMovie($id);\n    }\n}\n```\n\n### Dependency injection example\n\n```php\nuse Tmdb\\Repository\\MovieRepository;\n\nclass MoviesController {\n\n    private $movies;\n\n    function __construct(MovieRepository $movies)\n    {\n        $this-\u003emovies = $movies;\n    }\n\n    function index()\n    {\n        // returns information of a movie\n        return $this-\u003emovies-\u003egetPopular();\n    }\n}\n```\n\n### Listening to events\n\nWe can easily listen to events that are dispatched using the Laravel event dispatcher that we're familiar with.\nThe following example listens to any request that is made and logs a message.\n\n```php\nuse Log;\nuse Event;\nuse Tmdb\\Event\\TmdbEvents;\nuse Tmdb\\Event\\RequestEvent;\n\nEvent::listen(TmdbEvents::REQUEST, function(RequestEvent $event) {\n    Log::info(\"A request was made to TMDB\");\n    // do stuff with $event\n});\n```\n\nIn Laravel 5 instead of using the `Event` facade we could also have used the `EventServiceProvider` to register our event listener.\n\n### Image helper\n\nYou can easily use the `ImageHelper` by using dependency injection. The following example shows how to show the poster image of the 20 most popular movies.\n\n```php\nnamespace App\\Http\\Controllers;\n\nuse Tmdb\\Helper\\ImageHelper;\nuse Tmdb\\Repository\\MovieRepository;\n\nclass WelcomeController extends Controller {\n\n    private $movies;\n    private $helper;\n\n    public function __construct(MovieRepository $movies, ImageHelper $helper)\n    {\n        $this-\u003emovies = $movies;\n        $this-\u003ehelper = $helper;\n    }\n\n    /**\n     * Show the application welcome screen to the user.\n     *\n     * @return Response\n     */\n    public function index()\n    {\n        $popular = $this-\u003emovies-\u003egetPopular();\n\n        foreach ($popular as $movie)\n        {\n            $image = $movie-\u003egetPosterImage();\n            echo ($this-\u003ehelper-\u003egetHtml($image, 'w154', 260, 420));\n        }\n    }\n\n}\n```\n\nThe `Configuration` used by the `Tmdb\\Helper\\ImageHelper` is automatically loaded by the IoC container.\nIf you are a Laravel 5.1 user you could also use the blade's `@inject` functionality,\n\n```\n@inject('image', 'Tmdb\\Helper\\ImageHelper')\n\n@foreach ($movies as $movie)\n    {!! $image-\u003egetHtml($movie-\u003egetPosterImage(), 'w154', 260, 420) !!}\n@endforeach\n```\n\n### Registering plugins\n\nPlugins can be registered in a service provider using the `boot()` method.\n\n```php\nnamespace App\\Providers;\n\nuse Illuminate\\Support\\ServiceProvider;\nuse Tmdb\\HttpClient\\Plugin\\LanguageFilterPlugin;\n\nclass TmdbServiceProvider extends ServiceProvider {\n\n    /**\n     * Add a Dutch language filter to the Tmdb client\n     *\n     * @return void\n     */\n    public function boot()\n    {\n        $plugin = new LanguageFilterPlugin('nl');\n        $client = $this-\u003eapp-\u003emake('Tmdb\\Client');\n        $client-\u003egetHttpClient()-\u003eaddSubscriber($plugin);\n    }\n\n    /**\n     * Register services\n     * @return void\n     */\n    public function register()\n    {\n        // register any services that you need\n    }\n}\n```\n\n**For all all other interactions take a look at [php-tmdb/api](https://github.com/php-tmdb/api).**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-tmdb%2Flaravel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-tmdb%2Flaravel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-tmdb%2Flaravel/lists"}