Skip to content

Symfony 4,5 and 6 Bundle for TMDB ( The Movie Database ) API. Provides easy access to the php-tmdb/api library.

License

Notifications You must be signed in to change notification settings

php-tmdb/symfony

Repository files navigation

Description

A Symfony2 Bundle for use together with the wtfzdotnet/php-tmdb-api TMDB Wrapper.

Installation

Install Composer

$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer

Add the following to your require block in composer.json config

"wtfzdotnet/wtfz-tmdb-bundle": "~1.2"

Configuration

Add to your app/config/config.yml the following:

wtfz_tmdb:
    api_key: YOUR_API_KEY_HERE

That's all! Fire away!

Want to make use of default caching and/or logging?

This caching system will adhere to the TMDB API max-age values, if you have different needs like long TTL's you'd have to make your own implementation. We would be happy to intergrate more options, so please contribute.

wtfz_tmdb:
    api_key: YOUR_API_KEY_HERE
    cache:
        enabled: true
        #path: "%kernel.cache_dir%/tmdb"
    log:
        enabled: true
        #path: "%kernel.logs_dir%/tmdb.log"

Don't need the repositories?

You can disable repositories :

wtfz_tmdb:
    api_key: YOUR_API_KEY_HERE
    repositories:
        enabled: false

Don't need the twig extension?

You can disable the twig extension :

wtfz_tmdb:
    api_key: YOUR_API_KEY_HERE
    twig_extension:
        enabled: false

Usage

Obtaining the client

$client = $this->get('wtfz_tmdb.client');

Obtaining repositories

$movie = $this->get('wtfz_tmdb.movie_repository')->load(13);

An overview of all the repositories can be found in the services configuration repositories.xml.

There is also a Twig helper that makes use of the Tmdb\Helper\ImageHelper to output urls and html.

{{ movie.backdropImage|tmdb_image_url }}

{{ movie.backdropImage|tmdb_image_html('original', null, 50)|raw }}

For all all other interactions take a look at wtfzdotnet/php-tmdb-api.