Download the PHP package php-tmdb/api without Composer

On this page you can find all versions of the php package php-tmdb/api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package api

A PHP Wrapper for use with the TMDB API.

License License Build Status Build Status codecov PHP Total Downloads

Tests run with minimal, normal and development dependencies.

Buy me a coffee, or a beer :-)

My stomach will appreciate your donation!

Main features

Attention newcomers to php

If you are new to php and starting a project to learn, I'd recommend you skip down to the installation, and then follow the quickstart that's just for you!

I do advise you to take a broader look later on what all these PSR standards mean and do for the php community :-).

PSR Compliance

We try to leave as many options open to the end users of this library, as such with 4.0 changes have been made to introduce PSR compliance where we can. You bring the dependencies you prefer that are compliant with PSR standards, register the listeners, and we handle the rest.

Framework implementations

Installation

Install composer.

Before we can install the api library, you need to install a set of dependencies that provide the following implementations.

Dependencies you have to fulfill yourself

I urge you to implement the optional caching implementation

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. 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.

Even though themoviedb.org disabled rate limiting since the end of 2019, I'd still recommend enabling the cache to make your application run a bit smoother. As such the 427 retry subscriber in previous versions is not present anymore.

Not only will this make your application more responsive, by loading from cache when we can, it also decreases the amount of requests we need to send.

Optional dependencies

Install php-tmdb/api

If the required dependencies above are met, you are ready to install the library.

Include Composer's autoloader:

To use the examples provided, copy the examples/apikey.php.dist to examples/apikey.php and change the settings.

New to PSR standards or composer?

If you came here looking to start a fun project to start learning, the above might seem a little daunting.

Don't worry! The documentation here was setup with beginners in mind as well.

We also provide a bunch of examples in the examples/ folder.

To get started;

Now that we have everything we need installed, let's get started setting up to be able to use the library.

Quick setup

Review the setup files below and go over the examples folder, for example examples/movies/api/get.php files.

Constructing the Client

If you have chosen different implementations than the examples suggested beforehand, obviously all the upcoming documentation won't match. Adjust accordingly to your dependencies, we will go along with the examples given earlier.

General API Usage

If you're looking for a simple array entry point the API namespace is the place to be, however we recommend you use the repositories and model's functionality up ahead.

If you want to provide any other query arguments.

For all further calls just review the examples provided, or the API classes themselves.

Model Usage

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.

For all further calls just review the examples provided, or the model's themselves.

Event Dispatching

We (can) dispatch the following events inside the library, which by using event listeners you could modify some behavior.

HTTP Client exceptions

TMDB API exceptions

Hydration

The current implementation within the event dispatcher causes significant overhead, you might actually not want at all.

In the future we will look into this further for improvement, for now we have bigger fish to catch.

From 4.0 moving forward by default the hydration events have been disabled.

To re-enable this functionality, we recommend only using it for models you need to modify data for;

If that configuration has been applied, also make sure the event dispatcher you use is aware of our HydrationListener;

If you re-enable this functionality without specifying any models, all hydration will be done through the event listeners.

Requests & Responses

Event listeners

We have a couple of optional event listeners that you could add to provide additional functionality.

Caching

Instead of constructing the default RequestListener, construct the client with the Psr6CachedRequestListener.

The current implementation will change again in the future, it will either involve a small change in listener registration, or will just happen without you being aware. We currently base this on php-http/cache-plugin, which pulls in extra dependencies we don't really use. Since caching is quite a subject itself, for now we have chosen the "quick 'n dirty way".

Logging

The logging is divided in a couple of listeners, so you can decide what you want to log, or not. All of these listeners have support for writing custom formatted messages. See the relevant interfaces and classes located in the Tmdb\Formatter namespace.

Instead of monolog you can pass any PSR-3 compatible logger.

Tmdb\Event\Listener\Logger\LogApiErrorListener

This will log exceptions thrown when a response has successfully been received, but the response indicated the request was not successful.

Tmdb\Event\Listener\Logger\LogHttpMessageListener

This will log outgoing requests and responses.

In case of any other PSR-18 client exceptions ( connection errors for example ), these will also be written to the log.

Tmdb\Event\Listener\Logger\LogHydrationListener

This will log hydration of models with (optionally) their data, useful for debugging.

For calls with a lot of appended data, this quickly becomes a large dump in the log file, and I would advise to only use this when necessary.

Do not enable the hydration data dumping on production, it will generate massive logs.

Adult filter

To enable inclusion of results considered "adult", add the following listener.

Language filter

To enable filtering contents on language, add the following listener.

Region filter

To enable filtering contents on region, add the following listener.

Guest session

If you want to make use of guest sessions, you need to specify this explicitly on the client.

Image Helper

An ImageHelper class is present to take care of the images, which does require the configuration to be loaded:

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


All versions of api with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3 || ^7.4 || ^8.0 || ^8.1
ext-json Version *
symfony/options-resolver Version >=4.4 || ^5 || ^6
psr/cache Version ^1 || ^2 || ^3
psr/simple-cache Version ^1 || ^2 || ^3
psr/event-dispatcher Version ^1
psr/event-dispatcher-implementation Version ^1
psr/log Version ^1 || ^2 || ^3
php-http/discovery Version ^1.11
psr/http-client Version ^1
psr/http-client-implementation Version ^1
psr/http-factory Version ^1
psr/http-factory-implementation Version ^1
psr/http-message Version ^1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package php-tmdb/api contains the following files

Loading the files please wait ....