PHPackages                             technosophos/solrapi - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. technosophos/solrapi

ActiveLibrary[Search &amp; Filtering](/categories/search)

technosophos/solrapi
====================

A chaining (fluent, builder) API for querying Apache Solr.

2.0.0-alpha3(14y ago)33102[2 issues](https://github.com/technosophos/SolrAPI/issues)MIT or GPLv2PHPPHP &gt;=5.3.0

Since Feb 3Pushed 14y ago2 watchersCompare

[ Source](https://github.com/technosophos/SolrAPI)[ Packagist](https://packagist.org/packages/technosophos/solrapi)[ Docs](https://github.com/technosophos/SolrAPI)[ RSS](/packages/technosophos-solrapi/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

SolrAPI: A PHP library for working with Solr
============================================

[](#solrapi-a-php-library-for-working-with-solr)

This library provides a chainable (Fluent) API for building and executing Solr queries.

Installation
------------

[](#installation)

This library depends on the SolrPHPClient library, which handles Solr client-server communication.

### With Packagist/Composer (recommended)

[](#with-packagistcomposer-recommended)

1. [Get Composer](http://getcomposer.org/composer.phar) if you don't have it already.
2. In your own `composer.json`, add `technosophos/LibRIS` in the "require" section.

```
{
  "require" {
    "technosophos/LibRIS": ">=1.0.0"
  }
}
```

When you run `php composer.phar install` or `php composer.phar update`in your package, the latest stable version of SolrAPI (along with its dependencies) will be added.

Note that you can use Composer to manage many, if not all, of your library dependencies.

### Ye Olde-Fashioned Way

[](#ye-olde-fashioned-way)

1. Install the [SolrPHPClient library](http://code.google.com/p/solr-php-client/).
2. Download this libary
3. Put this library somewhere where your PHP interpreter can see it
4. Include it in your scripts (`require 'solrapi.inc'`)

That's all there is to it.

### For Drupal Users

[](#for-drupal-users)

*UPDATE: The Drupal version is on branch `1.0.0`. Drupal has drifted away from mainstream PHP, and may or may not work with the 2.x version of SolrAPI.*

This library contains some additional features targeted toward the [Drupal apachesolr module](http://drupal.org/project/apachesolr).

To use this under Drupal, you merely need to install and configure the `apachesolr` module, and then include this library. (I wrote a simple module to do the including.)

Using the library
-----------------

[](#using-the-library)

Since SolrAPI uses a function, and functions cannot be autoloaded, if you want to use `solarq()` you will need to do this:

```

```

If you would rather have SPR-0 autoloading, and don't care about the `solarq()` function, you can put the `SolrAPI` source in your include path, turn on your autoloader, and use `SolrAPI` like this:

```

```

The query object can be chained just like a `solrq()` can.

The code is documented very well. Here's a simple example of how this library is used:

```

```

The above executes a simple query for the string 'Search me'. Far more sophisticated queries can be built, though:

```
