Skip to content
This repository has been archived by the owner on Jan 10, 2018. It is now read-only.

vierbergenlars/Forage-PHP-Client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Forage-PHP-Client

Build Status Scrutinizer Quality Score Latest Stable Version Total Downloads

A PHP client for the Forage search server

License: MIT

Installation

$ composer require vierbergenlars/forage-client:~0.2@alpha

Usage example

<?php

use vierbergenlars\Forage\Transport\Http as HttpTransport;
use vierbergenlars\Forage\Client;

$transport = new HttpTransport;
$client = new Client($transport);

$query = $client->createQueryBuilder()
               ->setSearchQuery('Funny cat')
               ->setOffset(($_GET['page']-1)*10)
               ->setLimit(10)
               ->addSearchField('title')
               ->addFacet('media_type')
               ->addFilter('animal', 'cat')
               ->addFilter('categories', array('funny', 'lol'))
               ->addWeight('title', 3)
               ->getQuery();

$results = $query->execute();

echo 'Total hits: '.$results->getTotalHits();
foreach($result as $hit) {
    /* @var $hit \vierbergenlars\Forage\SearchResult\Hit */
    echo ' - '.$hit->getDocument()['title'].' (score: '.$hit->getScore().'; id='.$hit->getId().')';
}

Full documentation is available in the wiki, or have a look at the API documentation

About

A PHP client for the Forage search server

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages