How to install ExifTool with Composer

Reply

I’m working on a PHP project, that uses Phil Harveys excellent ExifTool to read Exif and XMP tags from photos. Since ExifTool is written in Perl, there is of course no composer.json to install this dependency directly with Composer. But you can create your own package information in your master composer.json as follows:

{
    ...
    "repositories": [
        ...        
        {
            "type": "package",
            "package": {
                "name": "philharvey/exiftool",
                "version": "10.75",
                "dist": {
                    "url": "https://sno.phy.queensu.ca/~phil/exiftool/Image-ExifTool-10.75.tar.gz",
                    "type": "tar"
                }
            }
        }
    ],
    "require": {
        ...
        "philharvey/exiftool": "10.*"
    }
}

This will automatically download ExifTool version 10.75 and extract it into the vendor folder /vendor/philharvey/exiftool/

Note, that the package type ‘tar’ should extract the file completely. If that is not the case, make sure you have the latest composer version 1.6.2 installed. Some Linux distributions (e.g. Linux Mint 18.3 and probably Ubuntu 16.4 too) are still on version 1.0.0-beta2, which does not support extracting ‘tar.gz’. Read my quick tutorial on how to upgrade composer on Linux Mint 18.3.

 

How to update Composer on Linux Mint 18.3

1 Reply

When you install Composer (the dependency manager for PHP) globally on Linux Mint 18.3 with the package manager…

$ sudo apt install composer
$ composer -V
Composer version @package_branch_alias_version@ (1.0.0-beta2) 2016-03-27 16:00:34

…you’ll get the totally outdated version 1.0.0-beta2. The problem is that this version does not support extracting compressed package files ‘tar.gz’. It also does not support updating itself with:

$ composer selfupdate

So, you need to download the latest composer version (currently 1.6.2) manually and then put it into the directory /usr/local/bin/composer (which overrides /usr/bin/composer)

$ sudo mv composer.phar /usr/local/bin/composer
$ chmod +x /usr/local/bin/composer

now login – logout to apply the changes, voila:

$ composer -V
Composer version 1.6.2 2018-01-05 15:28:41