rewrewby / tmdb-symfony
Symfony2 Bundle for TMDB ( The Movie Database ) API. Provides easy access to the php-tmdb/api library.
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 27
Type:symfony-bundle
Requires
- php: >=5.4.0
- doctrine/doctrine-cache-bundle: ~1.0
- php-tmdb/api: dev-feature/guzzle-6
- symfony/config: >=2.3,<4
- symfony/dependency-injection: >=2.3,<4
- symfony/event-dispatcher: >=2.3,<4
- symfony/http-kernel: >=2.3,<4
- twig/twig: ~1.11|~2.0
Requires (Dev)
- phpunit/phpunit: ^4.8
- symfony/framework-bundle: >=2.3,<4
This package is not auto-updated.
Last update: 2025-01-04 20:04:25 UTC
README
A Symfony2 Bundle for use together with the 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
"php-tmdb/symfony": "~2.0"
Configuration
Register the bundle in app/AppKernel.php
:
public function registerBundles() { ... new Tmdb\SymfonyBundle\TmdbSymfonyBundle() ... }
If you haven't had the DoctrineCacheBundle yet, also register it:
public function registerBundles() { ... new \Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle() ... }
Add to your app/config/config.yml
the following:
tmdb_symfony: api_key: YOUR_API_KEY_HERE
Configure caching
First create a new doctrine_cache provider with a caching provider of your preference.
doctrine_cache: providers: tmdb_cache: file_system: directory: %kernel.root_dir%/cache/tmdb
Then update the tmdb configuration with the alias:
tmdb_symfony: options: cache: enabled: true handler: tmdb_cache
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.
Want to make use of logging?
tmdb_symfony: api_key: YOUR_API_KEY_HERE options: cache: enabled: true log: enabled: true #path: "%kernel.logs_dir%/tmdb.log"
Disable repositories :
tmdb_symfony: api_key: YOUR_API_KEY_HERE repositories: enabled: false
Disable twig extension :
tmdb_symfony: api_key: YOUR_API_KEY_HERE twig_extension: enabled: false
Disable https :
tmdb_symfony: api_key: YOUR_API_KEY_HERE options: secure: enabled: false
Full configuration with defaults :
tmdb_symfony: api_key: YOUR_API_KEY_HERE repositories: enabled: true # Set to false to disable repositories twig_extension: enabled: true # Set to false to disable twig extensions options: adapter: null secure: true # Set to false to disable https host: "api.themoviedb.org/3/" session_token: null cache: enabled: true # Set to false to disable cache path: "%kernel.cache_dir%/themoviedb" handler: null subscriber: null log: enabled: false # Set to true to enable log path: "%kernel.logs_dir%/themoviedb.log" level: DEBUG handler: null subscriber: null
Usage
Obtaining the client
$client = $this->get('tmdb.client');
Obtaining repositories
$movie = $this->get('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 php-tmdb/api.