Installation and Configuration

Basically, you simply need to extract the files from the distribution archives main directory somewhere into your web tree, and could start straight away (at least with using the demo). Well, in that case the cache would be disabled, and images wouldn't work – but everything else would be ready. But at the lastest when you want to use the API with your applications, we would need some "fine tuning".

What is the recommended installation method?

That depends very much on your environment. If you are running a Linux distribution supporting *.deb or *.rpm packages (optionally with an APT or YUM repository), you should use these packages (for the repository, please visit http://apt.izzysoft.de/ to find more details). If you cannot use one of these two package types, the Tar-Archive contains a Makefile you can use by simply changing to the directory containing the unpacked archive and call make install.

There are a few advantages above mentioned installation methods have in common:

  • all files will automatically be put to the right places
  • caching and images will automatically be setup properly
  • everything can be easily cleanly uninstalled

If none of these automatic installation methods can be used, you will have to install the software manually. Just read on for more details.

Which files are really needed?

The API consists of all the *.class.php files, which must reside together in the same directory:

  • mdb_*.class.php: Base classes. All others are built on top of these.
  • imdb*.class.php: Classes used for the IMDB sites
  • classes specific for other sources (if available)

All other files are either documentation or demo files and are not needed to use the API.

Where should the files go?

This very much depends on the intended use. If you want to integrate the IMDBPHP API into your application, you will probably put them in some directory inside the app. Otherwise, if the API should be globally available, you should put them into some directory contained in your PHP include path (see your php.ini for the keyword include_path, or the web server configuration for the corresponding keyword – for Apache, this is e.g. php_value include_path). Important is that all these files are kept together to work without changing them. If you use one of the recommended installation methods, this will be done automatically: With v0.9.5 and up the API files will be placed into /usr/share/php, which is in the include_path of the php.ini shipped with most distributions.

What needs to be configured?

Basically, it works "out of the box". But there are some things you may want to adjust. We will walk here through the configuration.

While the defaults are set in imdb_config.class.php, you should not touch that file; instead, take a look at the conf/ sub-directory, where you can find an example .ini file. Start with a copy of that as described in its head (name it e.g. 900_localconf.ini), and walk through its settings.

Everything you don't want to touch, you can also comment out or even completely remove; defaults in imdb_config.class.php will take care for that. But you should at least make sure your cache and image directories point to existing locations with adequate permissions.

Site Options

names and AKAs known, so also localized movie names should be found. You can change this option even at runtime to switch the server.
Option Default Description
imdbsiteakas.imdb.comThe IMDB website of your preference. By default it is set to akas.imdb.com since that site will handle all movie
pilot_imdbfill0 (NO_ACCESS)This was previously used for Moviepilot, which didn't offer all the information available at the IMDB sites. So gaps can be automatically closed from IMDB changing the default from NO_ACCESS (0) to one of the other variants. Provided you st the constant PILOT_IMDBFALLBACK to TRUE before including the classes. This can be achieved using the statement define('PILOT_IMDBFALLBACK',TRUE);. Defaults are, as mentioned, not to use any IMDB fallback: This way you can be pretty sure the content obtained does not violate any copyrights, if the source used serves its content under a free license as e.g. Creative Commons license (as e.g. OFDb does). Though Moviepilot is no longer supported (they dropped their API), these settings are preserved for alternatives to drop in.

Caching Options

set to an existing path with read/write permission for the web server.
Option Default Description
cachedircache/ (relative to the config class file)Where to store the cache (if enabled). This directory must be read/write accessible for the web server. You can specify either relative or absolute path.
usecache1 (TRUE)If a requested page is found in the cache, shall it be used to setup the data (TRUE) - or shall we ignore it and retrieve the page again from its origin (FALSE)?
storecache1 (TRUE)If a page was retrieved from its origin, shall it be stored into the cache for later reference? Requires the cache directory to be
usezip1 (TRUE)Shall the cache files be stored in compressed form?
converttozip1 (TRUE)If there are uncompressed pages in the cache, shall they be compressed when accessed?
cache_expire3600 (1h)For how many seconds shall the cache stay valid? Files older than this will be purged the next time the cache is probed.

Image Options

Option Default Description
photodir./images/ (relative to working path)Directory where retrieved images should be stored. Must be inside the servers DOCUMENT_ROOT if you want this images to be displayed with your web pages, and as with the cachedir above, the web server needs permission to read and write here.
photoroot./images/URL equivalent for the photodir – i.e. it must start at the servers DOCUMENT_ROOT if you specify an absolute path: If your DOCUMENT_ROOT e.g. is /var/www, and your images are stored in /var/www/photos, the absolute URL would be /photos/.

Tweaking Options

Option Default Description
maxresults20Limit the result set displayed on a movie search. A value of "0" means no limit, everything else sets the maximum results displayed.
searchvariantizzyIf you are not happy with the results retrieved on a movie search, you may want to try one of the search variants (different options will be set on the movie search). Available variants are sevec and moonface, the default is izzy. Only applies to the IMDB classes.
default_agentMozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3User agent (if none is detected). Normally, the agent of the browser used is being presented.
force_agent(empty)Enforce the use of a special user agent, regardless whether one was detected from a browser.
trigger_referer1 (TRUE)Several features require a referer URL to be send. IMDBPHP usually sends the page processed as such. You can suppress this with this setting.
debug0Show debug messages (1) or not (0)?

Alternate Configuration File

You can also define an alternate configuration file by defining a constant named IMDBPHP_CONFIG before including imdb_base.class.php:

<?php
define('IMDBPHP_CONFIG','/var/www/myproject/imdb_config.php');
require_once(imdb_base.class.php);
// more code goes here
?>

This way it is possible to easily use different settings for different purposes, if needed. If you make use of this feature, keep in mind the conf/ directory will be expected in the same directory as this class file.

Last modified 3 years ago Last modified on Oct 15, 2013 8:44:06 PM