bboer / sphinxsearch
There is no license information available for the latest version (dev-master) of this package.
Search any sphinx index
dev-master
2013-10-10 12:43 UTC
Requires
- php: >=5.4
- zendframework/zendframework: 2.*
This package is not auto-updated.
Last update: 2024-11-05 02:49:24 UTC
README
By [Bart de Boer] (http://github.com/bboer/)
Introduction
When you like to search sphinx generated indexes from a zf2 application, use this module.
Installation
-
Preparation
Make sure you have a working Sphinx server anywhere
-
Require SphinxSearch
From within your project execute the following:
php composer.phar require bboer/sphinxsearch
-
Configure SphinxSearch
copy sphinxsearch.local.php.dist to your /config/autoload/sphinxsearch.local.php
Sample configuration:
<?php return array( 'sphinx_search' => array( 'server' => array( 'host' => 'mysphinxhost.com', 'port' => 9312, ), ), );
Usage
-
Using the Search service using the ServiceTrait
<?php namespace MyModule\MySpace; use Zend\ServiceManager\ServiceLocatorAwareInterface; class MyService implements ServiceLocatorAwareInterface { use \SphinxSearch\ServiceManager\ServiceTrait; public function myServiceMethod() { // Get the results from the SphinxSearch service $results = $this->getSphinxSearchService()->search( 'person_main', $filters, $queries, $fieldWeights, $limit, $offset ); // NOTE: Used variables are not defined and intended as an example } }
-
Using the Search service by locating it through the ServiceLocator
<?php namespace MyModule\MySpace; use Zend\ServiceManager\ServiceLocatorAwareInterface; class MyService implements ServiceLocatorAwareInterface { use \SphinxSearch\ServiceManager\ServiceTrait; public function myServiceMethod() { // Get the SphinxSearch Search service $searchService = $this->getServiceLocator()->get( 'SphinxSearch\Search\Search' ); // Get the results from the SphinxSearch service $results = $searchService->search( 'person_main', $filters, $queries, $fieldWeights, $limit, $offset ); // NOTE: Used variables are not defined and intended as an example } }