NinoSkopac / PhpTikaWrapper

Simple PHP Wrapper for Apache Tika
60 stars 25 forks source link

This is a simple PHP Wrapper for Apache Tika.

It allows the developer to retrieve text, metadata and language from complex documents.

Supported formats

It supports opendocument, office .doc and .docx, pdf, images, videos and a lot more !

See http://tika.apache.org/1.1/formats.html for details.

Install with composer

Add the package dependency enzim/tika-wrapper in your composer.json

    {
        "require": {
            "ninoskopac/php-tika-wrapper": "~1.0" 
        }   
    }

Install the new package with composer, and that's it!

php composer.phar install

For convenience, the package include the tika-app jar file, which is quite big (25MB). The download may take time!

See http://packagist.org for more details. (Don't forget to add require 'vendor/.composer/autoload.php'; in your autoloading php file).

Example installation/usage

See example/ (more docs to come soon) for an example:

    git clone git@github.com:pierroweb/PhpTikaWrapper.git
    cd PhpTikaWrapper

    cd example/with-composer
    curl -s http://getcomposer.org/installer | php
    php composer.phar install
    php usage.php

Usage

In your own project, assuming you have an opendocument test.odt in the current directory

    <?php
    use Enzim\Lib\TikaWrapper\TikaWrapper;

    $testFile = __DIR__."/test.odt";

    $plaintext = TikaWrapper::getText($testFile);
    $metadataArray = TikaWrapper::getMetaData($testFile);
    $language = TikaWrapper::getLanguage($testFile);

Available methods (they all take a string, the full path of the file, as argument)

TODO

Support for Tika-server

Supported by this lib: https://github.com/vaites/php-apache-tika

Credits