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:

  • browseremulator.class.php - used to communicate with other web servers
  • imdb_base.class.php - common methods for all classes
  • imdb_config.class.php - the configuration file
  • imdb.class.php - the API class for movie info
  • imdb_charts.class.php - class for Top-Charts
  • imdb_nowplaying.class.php - what is playing right now in US movie theaters
  • imdb_person.class.php - the API class for staff info
  • imdb_request.class.php - wrapper to the browser emulator
  • imdb_trailers.class.php - class to retrieve the real trailer URLs

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 - which you already guessed correctly to be found in imdb_config.class.php - to discuss all issues.

All configuration options in imdb_config.class.php are prefixed by the term $this->, since we configure a class. The prefix $this-> will be omitted in the following description to make it easier to read:

General Options

Option Description
imdbsiteThe IMDB website of your preference. By default it is set to akas.imdb.com since that site will handle all movie names and AKAs known, so also localized movie names should be found. You can change this option even at runtime to switch the server.
debugShow debug messages (1) or not (0)?

Caching Options

Option Description
cachedirWhere 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.
usecacheIf 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)?
storecacheIf a page was retrieved from its origin, shall it be stored into the cache for later reference? Requires the cache directory to be set to an existing path with read/write permission for the web server.
usezipShall the cache files be stored in compressed form?
converttozipIf there are uncompressed pages in the cache, shall they be compressed when accessed?
cache_expireFor 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 Description
photodirDirectory 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.
photorootURL 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 Description
maxresultsLimit the result set displayed on a movie search. A value of "0" means no limit, everything else sets the maximum results displayed.
searchvariantIf 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.

Alternate Configuration File

Starting with version 1.0.8 (or revision r170), 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.

Last modified by izzy, 02/25/09 16:51:59 (13 months ago)