Download the PHP package tiagosampaio/tmdb-api-php without Composer
On this page you can find all versions of the php package tiagosampaio/tmdb-api-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tiagosampaio/tmdb-api-php
More information about tiagosampaio/tmdb-api-php
Files in tiagosampaio/tmdb-api-php
Package tmdb-api-php
Short Description PHP wrapper for TMDB (TheMovieDatabase) API v3. Supports two types of approaches, one modelled with repositories, models and factories. And the other by simple array access to RAW data from The Movie Database.
License MIT
Homepage https://github.com/wtfzdotnet/php-tmdb-api
Informations about the package tmdb-api-php
A PHP Wrapper for use with the TMDB API.
Inspired by php-github-api, php-gitlab-api and the Symfony Community.
If you have any questions or feature requests, please visit the google+ community.
Stable
Currently unit tests are run on travis, with the following versions:
- 5.6
- 7.0
- 7.1
- HHVM (failures allowed)
- nightly (failures allowed)
Features
Main features
- An complete integration of all the TMDB API has to offer (accounts, movies, tv etc. if something is missing I haven't added the updates yet!).
- Array implementation of the movie database (RAW)
- Model implementation of the movie database (By making use of the repositories)
- An
ImageHelper
class to help build image urls or html elements.
Other things worth mentioning
- Retry subscriber enabled by default to handle any rate limit errors.
- Caching subscriber enabled by default, based on
max-age
headers returned by TMDB, requiresdoctrine-cache
. - Logging subscriber and is optional, requires
monolog
. Could prove useful during development.
Plug-ins
- Symfony
- Laravel
Installation
Install Composer
You are not obliged to move the composer.phar
file to your /usr/local/bin
, it is however considered easy to have an global installation.
Add the following to your require block in composer.json
config
If your new to composer and have no clue what I'm talking about
Just create a file named composer.json
in your document root:
Now let's install and pull in the dependencies!
Include Composer's autoloader:
To use the examples provided, copy the apikey.php.dist
to apikey.php
and change the settings.
Constructing the Client
First we always have to construct the client:
If you'd like to make unsecure requests (by default we use secure requests).
Caching is enabled by default, and uses a slow filesystem handler, which you can either:
-
Replace the
path
of the storage of, by supplying the option in the client: - Or replace the whole implementation with another CacheStorage of Doctrine:
This will only keep cache in memory during the length of the request, see the documentation of Doctrine Cache for the available adapters.
Strongly against this, disabling cache:
If you want to add some logging capabilities (requires monolog/monolog
), defaulting to the filesystem;
However during development you might like some console magic like ChromePHP
or FirePHP
;
General API Usage
If your looking for a simple array entry point the API namespace is the place to be.
If you want to provide any other query arguments.
Model Usage
However the library can also be used in an object oriented manner, which I reckon is the preferred way of doing things.
Instead of calling upon the client, you pass the client onto one of the many repositories and do then some work on it.
The repositories also contain the other API methods that are available through the API namespace.
Some other useful hints
Event Dispatching
Since 2.0 requests are handled by the EventDispatcher
, which gives you before and after hooks, the before hook allows an event to stop propagation for the
request event, meaning you are able to stop the main request from happening, you will have to set a Response
object in that event though.
See the files for RequestSubscriber respectively.
Image Helper
An ImageHelper
class is provided to take care of the images, which does require the configuration to be loaded:
Plug-ins
At the moment there are only two useful plug-ins that are not enabled by default, and you might want to use these:
Tries to fetch everything it can in Dutch.
We like naughty results, if configured this way, provide false
to filter these out.
Collection Filtering
We also provide some easy methods to filter any collection, you should note however you can always implement your own filter easily by using Closures:
These basic filters however are already covered in the Images
collection object:
And there are more Collections which provide filters, but you will find those out along the way.
The GenericCollection
and the ResultCollection
The GenericCollection
holds any collection of objects (e.g. an collection of movies).
The ResultCollection
is an extension of the GenericCollection
, and inherits the response parameters _(page, total_pages, totalresults) from an result set,
this can be used to create paginators.
Help & Donate
If you use this in a project whether personal or business, I'd like to know where it is being used, so please drop me an e-mail! :-)
If this project saved you a bunch of work, or you just simply appreciate my efforts, please consider donating a beer (or two ;))!
All versions of tmdb-api-php with dependencies
ext-curl Version *
symfony/event-dispatcher Version >=2.4,<5
symfony/options-resolver Version >=2.6,<5
guzzlehttp/guzzle Version ~6.0
psr/log Version ~1.0
doctrine/cache Version ^1.6
kevinrob/guzzle-cache-middleware Version ^1.2 || ^2.0
rtheunissen/guzzle-log-middleware Version ^0.4.0