2017 © Pedro Peláez
 

symfony-bundle wtfz-tmdb-bundle

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

image

wtfzdotnet/wtfz-tmdb-bundle

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

  • Saturday, January 20, 2018
  • by wtfzdotnet
  • Repository
  • 4 Watchers
  • 24 Stars
  • 216 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 17 Forks
  • 2 Open issues
  • 16 Versions
  • 0 % Grown

The README.md

A Symfony Bundle for use together with the php-tmdb/api TMDB API Wrapper.

License License Build Status Build Status codecov PHP Total Downloads, (*1)

Compatible with Symfony 4 and 5, PHP 7.3 and up., (*2)

Installation

  • Install Composer
  • Install php-tmdb/api dependencies
    • For development within Symfony we recommend making use of Symfony's PSR-18 HTTP Client Symfony\Component\HttpClient\Psr18Client, as when non-cached results pass your profiler will be filled with data.

Then require the bundle:, (*3)

composer require php-tmdb/symfony:^4

Configuration

Register the bundle in app/bundles.php:, (*4)

<?php

return [
    // --- snip ---
    Tmdb\SymfonyBundle\TmdbSymfonyBundle::class => ['all' => true],
];

Add to your app/config/config.yml the following, or replace values with services of your choice ( PSR-18 Http Client / PSR-17 Factories ):, (*5)

tmdb_symfony:
    api_key: YOUR_API_KEY_HERE
    options:
        http:
            client: Symfony\Component\HttpClient\Psr18Client
            request_factory: Nyholm\Psr7\Factory\Psr17Factory
            response_factory: Nyholm\Psr7\Factory\Psr17Factory
            stream_factory: Nyholm\Psr7\Factory\Psr17Factory
            uri_factory: Nyholm\Psr7\Factory\Psr17Factory

services.yaml:, (*6)

services:
    Symfony\Component\HttpClient\Psr18Client:
        class: Symfony\Component\HttpClient\Psr18Client

    Nyholm\Psr7\Factory\Psr17Factory:
        class: Nyholm\Psr7\Factory\Psr17Factory

Configure caching, (*7)

You can use any PSR-6 cache you wish to use, we will simply use symfony's cache., (*8)

When making use of caching, make sure to also include php-http/cache-plugin in composer, this plugin handles the logic for us, so we don't have to re-invent the wheel., (*9)

You are however also free to choose to implement your own cache listener, or add the caching logic inside the http client of your choice., (*10)

```shell script composer require php-http/cache-plugin:^1.7, (*11)


First off configure the cache pool in symfony `config/cache.yaml`: ```yaml framework: cache: pools: cache.tmdb: adapter: cache.adapter.filesystem default_lifetime: 86400

Then in your tmdb_symfony.yaml configuration enable the cache and reference this cache pool:, (*12)

tmdb_symfony:
  api_key: YOUR_API_KEY_HERE
  cache:
    enabled: true
    adapter: cache.tmdb

Want to make use of logging?, (*13)

Logging capabilities as of 4.0 allow you to make a fine-grained configuration., (*14)

You can use any PSR-3 logger you wish to use, we will simply use monolog., (*15)

First off configure the monolog and add a channel and handler:, (*16)

monolog:
    channels:
        - tmdb
    handlers:
        tmdb:
            type: stream
            path: "%kernel.logs_dir%/php-tmdb--symfony.%kernel.environment%.log"
            level: info
            channels: ["tmdb"]

Then in your tmdb_symfony.yaml configuration:, (*17)

tmdb_symfony:
  api_key: YOUR_API_KEY_HERE
  log:
    enabled: true
    adapter: monolog.logger.tmdb
    hydration:
      enabled: true
      with_hydration_data: false # We would only recommend to enable this with an in-memory logger, so you have access to the hydration data within the profiler.
      adapter: null # you can set different adapters for different logs, leave null to use the main adapter.
      listener: Tmdb\Event\Listener\Logger\LogHydrationListener
      formatter: Tmdb\Formatter\Hydration\SimpleHydrationFormatter
    request_logging:
      enabled: true
      adapter: null # you can set different adapters for different logs, leave null to use the main adapter.
      listener: Tmdb\Event\Listener\Logger\LogHttpMessageListener
      formatter: Tmdb\Formatter\HttpMessage\SimpleHttpMessageFormatter
    response_logging:
      enabled: true
      adapter: null # you can set different adapters for different logs, leave null to use the main adapter.
      listener: Tmdb\Event\Listener\Logger\LogHttpMessageListener
      formatter: Tmdb\Formatter\HttpMessage\SimpleHttpMessageFormatter
    api_exception_logging:
      enabled: true
      adapter: null # you can set different adapters for different logs, leave null to use the main adapter.
      listener: Tmdb\Event\Listener\Logger\LogApiErrorListener
      formatter: Tmdb\Formatter\TmdbApiException\SimpleTmdbApiExceptionFormatter
    client_exception_logging:
      enabled: true
      adapter: null # you can set different adapters for different logs, leave null to use the main adapter.
      listener: Tmdb\Event\Listener\Logger\LogHttpMessageListener
      formatter: Tmdb\Formatter\HttpMessage\SimpleHttpMessageFormatter

Disable repositories :, (*18)

tmdb_symfony:
    api_key: YOUR_API_KEY_HERE
    repositories:
        enabled: false

Disable twig extension :, (*19)

tmdb_symfony:
    api_key: YOUR_API_KEY_HERE
    twig_extension:
        enabled: false

Disable https :, (*20)

tmdb_symfony:
    api_key: YOUR_API_KEY_HERE
    options:
        secure:
            enabled: false

Disable legacy aliases :, (*21)

Set to true to remove all legacy alises ( e.g. tmdb.client or tmdb.movie_repository )., (*22)

tmdb_symfony:
    api_key: YOUR_API_KEY_HERE
    disable_legacy_aliases: true

Full configuration with defaults :, (*23)

tmdb_symfony:
    api_key: YOUR_API_KEY_HERE
    cache:
        enabled: true
        adapter: cache.tmdb
    log:
        enabled: true
        adapter: monolog.logger.tmdb
        hydration:
            enabled: true
            with_hydration_data: false
            adapter: null
            listener: Tmdb\Event\Listener\Logger\LogHydrationListener
            formatter: Tmdb\Formatter\Hydration\SimpleHydrationFormatter
        request_logging:
            enabled: true
            adapter: null
            listener: Tmdb\Event\Listener\Logger\LogHttpMessageListener
            formatter: Tmdb\Formatter\HttpMessage\SimpleHttpMessageFormatter
        response_logging:
            enabled: true
            adapter: null
            listener: Tmdb\Event\Listener\Logger\LogHttpMessageListener
            formatter: Tmdb\Formatter\HttpMessage\SimpleHttpMessageFormatter
        api_exception_logging:
            enabled: true
            adapter: null
            listener: Tmdb\Event\Listener\Logger\LogApiErrorListener
            formatter: Tmdb\Formatter\TmdbApiException\SimpleTmdbApiExceptionFormatter
        client_exception_logging:
            enabled: true
            adapter: null
            listener: Tmdb\Event\Listener\Logger\LogHttpMessageListener
            formatter: Tmdb\Formatter\HttpMessage\SimpleHttpMessageFormatter
    options:
        bearer_token: YOUR_BEARER_TOKEN_HERE
        http:
            client: Symfony\Component\HttpClient\Psr18Client
            request_factory: Nyholm\Psr7\Factory\Psr17Factory
            response_factory: Nyholm\Psr7\Factory\Psr17Factory
            stream_factory: Nyholm\Psr7\Factory\Psr17Factory
            uri_factory: Nyholm\Psr7\Factory\Psr17Factory
        secure: true
        host: api.themoviedb.org/3
        guest_session_token: null
        event_dispatcher:
            adapter: event_dispatcher
        hydration:
            event_listener_handles_hydration: false
            only_for_specified_models: {  }
        api_token: YOUR_API_KEY_HERE # you don't have to set this if you set it at the root level
    session_token: null
    repositories:
        enabled: true
    twig_extension:
        enabled: true
    disable_legacy_aliases: false

Usage

Obtaining the client, (*24)

$client = $this->get(Tmdb\Client::class);

Obtaining repositories, (*25)

$movie = $this->get(\Tmdb\Repository\MovieRepository::class)->load(13);

An overview of all the repositories can be found in the services configuration repositories.xml., (*26)

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

{{ movie.backdropImage|tmdb_image_url }}

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

For all all other interactions take a look at php-tmdb/api., (*28)

The Versions

20/01 2018

dev-master

9999999-dev https://github.com/wtfzdotnet/php-tmdb-api

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api php symfony2 wrapper symfony3 symfony tv movie tvdb tmdb tv show cinema

20/01 2018

2.2.x-dev

2.2.9999999.9999999-dev https://github.com/wtfzdotnet/php-tmdb-api

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api php symfony2 wrapper symfony3 symfony tv movie tvdb tmdb tv show cinema

20/01 2018

2.2.0

2.2.0.0 https://github.com/wtfzdotnet/php-tmdb-api

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api php symfony2 wrapper symfony3 symfony tv movie tvdb tmdb tv show cinema

10/09 2017

2.1.x-dev

2.1.9999999.9999999-dev https://github.com/wtfzdotnet/php-tmdb-api

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api php symfony2 wrapper symfony3 symfony tv movie tvdb tmdb tv show cinema

10/09 2017

2.0.x-dev

2.0.9999999.9999999-dev https://github.com/wtfzdotnet/php-tmdb-api

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api php symfony2 wrapper symfony3 symfony tv movie tvdb tmdb tv show cinema

01/06 2017

v2.1.1

2.1.1.0 https://github.com/wtfzdotnet/php-tmdb-api

Symfony2 Bundle for TMDB ( The Movie Database ) API. Provides easy access to the php-tmdb/api library.

  Sources   Download

MIT

The Requires

 

The Development Requires

api php symfony2 wrapper symfony tv movie tvdb tmdb tv show

01/06 2017
16/10 2016

2.1.0

2.1.0.0 https://github.com/wtfzdotnet/php-tmdb-api

Symfony2 Bundle for TMDB ( The Movie Database ) API. Provides easy access to the php-tmdb/api library.

  Sources   Download

MIT

The Requires

 

The Development Requires

api php symfony2 wrapper symfony tv movie tvdb tmdb tv show

11/03 2016

v2.0.2

2.0.2.0 https://github.com/wtfzdotnet/php-tmdb-api

Symfony2 Bundle for TMDB ( The Movie Database ) API. Provides easy access to the php-tmdb/api library.

  Sources   Download

MIT

The Requires

 

The Development Requires

api php symfony2 wrapper symfony tv movie tvdb tmdb tv show

11/07 2015

v2.0.1

2.0.1.0 https://github.com/wtfzdotnet/php-tmdb-api

Symfony2 Bundle for TMDB ( The Movie Database ) API. Provides easy access to the php-tmdb/api library.

  Sources   Download

MIT

The Requires

 

api php symfony2 wrapper symfony tv movie tvdb tmdb tv show

14/04 2015

dev-feature-unit-tests

dev-feature-unit-tests https://github.com/wtfzdotnet/php-tmdb-api

Symfony2 Bundle for TMDB ( The Movie Database ) API. Provides easy access to the php-tmdb/api library.

  Sources   Download

MIT

The Requires

 

The Development Requires

api php symfony2 wrapper symfony tv movie tvdb tmdb tv show

05/04 2015

v2.0.0

2.0.0.0 https://github.com/wtfzdotnet/php-tmdb-api

Symfony2 Bundle for TMDB ( The Movie Database ) API. Provides easy access to the php-tmdb/api library.

  Sources   Download

MIT

The Requires

 

api php symfony2 wrapper symfony tv movie tvdb tmdb tv show

24/12 2014

dev-2.0-WIP

dev-2.0-WIP https://github.com/wtfzdotnet/php-tmdb-api

Symfony2 Bundle for TMDB ( The Movie Database ) API. Provides easy access to the wtfzdotnet/php-tmdb-api library.

  Sources   Download

MIT

The Requires

 

api php wrapper tv movie tvdb tmdb tv show

11/08 2014

v1.2.1

1.2.1.0 https://github.com/wtfzdotnet/php-tmdb-api

Symfony2 Bundle for TMDB ( The Movie Database ) API. Provides easy access to the wtfzdotnet/php-tmdb-api library.

  Sources   Download

MIT

The Requires

 

api php wrapper tv movie tvdb tmdb tv show

05/04 2014

v1.1.0

1.1.0.0 https://github.com/wtfzdotnet/php-tmdb-api

Symfony2 Bundle for TMDB ( The Movie Database ) API. Provides easy access to the wtfzdotnet/php-tmdb-api library.

  Sources   Download

MIT

The Requires

 

api php wrapper tv movie tvdb tmdb tv show

25/03 2014

v1.0.0

1.0.0.0 https://github.com/wtfzdotnet/php-tmdb-api

Symfony2 Bundle for TMDB ( The Movie Database ) API. Provides easy access to the wtfzdotnet/php-tmdb-api library.

  Sources   Download

MIT

The Requires

 

api php wrapper tv movie tvdb tmdb tv show