Integrating Yioop Libraries with Composer

Yioop provides a large variety of search-engine related and natural language related libraries that you might want to use in your own custom web application. Composer allows you to easily combine packages you need from several PHP projects into your project and manage their dependencies. In this article, we explore how to add Yioop to a project managed by Composer.
The Composer site describes how to download and install composer so that it can be run from the command line via commands like:
 composer some_directive_for_composer
Once you've installed composer you are set to create a new PHP project with it. Make a new folder, and open a command/terminal prompt in that folder. A composer project has at a minimum a composer.json file, and a sub-folder labeled vendor . The composer.json file is used to specify what version of which projects your project depends on, the vendor folder is where composer downloads and stores the correct versions of these projects.
To create a composer.json file, one can within the folder of our project type:
 composer init
This starts a wizard that guide you through the process of creating a composer.json file. You don't need to use this wizard, in fact, the file format is relatively simple and a composer.json file can be created/modified in a text editor. Below is a simple example composer.json file suitable for a project that uses Yioop.
     "name": "cpollett/test_composer",
     "description": "test out installing yioop as a required package",
     "authors": [
             "name": "Chris Pollett",
             "email": ""
     "config": {
        "secure-http": false
     "require": {
         "seekquarry/yioop": ">=3.3.0"
The name field is the vendor/package you are creating; the description field says what your software does authors says who you are; the repositories field explicitly says where to find the Yioop git repository; and the require field says what versions of which packages your project depends on, in this case, greater than or equal to version 3.0.1 of Yioop. The above composer.json file makes use of the website so that the Yioop repository doesn't explicitly have to be listed. If you don't want to use Packagist, you can add
     "repositories": [
             "type": "vcs",
             "url": ""
to the body of composer.json object above.
Below is a file test.php that we could create in our project folder that uses Yioop's library for stemming to stem the word jumping down to jump .
 namespace cpollett\test_composer;
 use seekquarry\yioop\library\PhraseParser;
 require_once "vendor/autoload.php";
 print_r(PhraseParser::stemTerms("jumping", 'en-US'));
The namespace line says the namespace of our project, the use line says that we will be using the PhraseParser class for the seekquarry\yioop\library package, the require_once loads the autoloader created by Composer for loading class files of packages it manages, finally, the print_r line calls the stemmer in Yioop's PhraseParser class, specifying the string to stem the words in as well as the language to use. To get Composer to create the autoload.php file as well as install any packages your project depends on, you simply type:
 composer install
Thereafter, if we want to upgrade our project's dependencies to their latest compatible versions we can type:
 composer update
To run the program we just created we can type:
 php test.php
Yioop has a variety of classes which might be useful to your project. The file YIOOP_FOLDER/src/examples/SearchApi.php shows an example of how to use Yioop's search api to do queries on an existing Yioop index. The PhraseParser class also has methods for char-gramming and segmenting. Yioop's Utility class has functions for various index compression codes. Yioop has classes for text summarization, url manipulation, suffix trees, tries, Bloom filters, compression algorithms, etc, all of which might be useful for project. The online Source Code Documention is a good place to start exploring what classes are available in Yioop.