2017 © Pedro PelĂĄez
 

symfony-bundle sphinx-bundle

Sphinx search in Symfony

image

gemorroj/sphinx-bundle

Sphinx search in Symfony

  • Saturday, July 16, 2016
  • by Gemorroj
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

HighcoSphinxBundle

This bundle use sphinx php api, you have to include on dir/sphinxapi.php your version of sphinxapi which is on package found on http://sphinxsearch.com/downloads/, (*1)

Installation:

  • Add to composer.json:
{
    "require": {
        "gemorroj/sphinx-bundle": "dev-master"
    }
}

Requirements:

  • PHP >= 5.5.9
  • Symfony >= 3.0

Simple example:

<?php
$client = $this->get('highco.sphinx.client');

$bridge = $this->get('highco.sphinx.pager.white_october.doctrine_orm');
// $bridge->setEntityManagerByName('my_custom_em');
// $bridge->setEntityManager($em);
$bridge->setRepositoryClass('HighcoUserBundle:User');
$bridge->setPkColumn('id');
$bridge->setSphinxResults($client->Query('Stéphane'));

$pager = $bridge->getPager();

Paging example

<?php
$itemsPerPage = 50;
$page = 1;

$client = $this->get('highco.sphinx.client');
$client->SetLimits( ($page -1) * $itemsPerPage, $itemsPerPage);

$bridge = $this->get('highco.sphinx.pager.white_october.doctrine_orm');
$bridge->setRepositoryClass('HighcoUserBundle:User');
$bridge->setPkColumn('id');
$bridge->setSphinxResults($client->Query('Stéphane'));

$pager = $bridge->getPager();
$pager->setMaxPerPage($itemsPerPage);
$pager->setCurrentPage($page);

Paging example with multiple queries

<?php
$itemsPerPage = 50;
$page = 1;

$client = $this->get('highco.sphinx.client');
$client->SetLimits( ($page -1) * $itemsPerPage, $itemsPerPage);

$bridge = $this->get('highco.sphinx.pager.white_october.doctrine_orm');
$bridge->setRepositoryClass('HighcoUserBundle:User');
$bridge->setPkColumn('id');

$client->AddQuery('Stéphane', 'address_book');
$client->AddQuery('Nikola', 'address_book');
$bridge->setSphinxResults($client->RunQueries(), true);

$pager = $bridge->getPager();
$pager->setMaxPerPage($itemsPerPage);
$pager->setCurrentPage($page);

Paging example /w discriminator attribute

<?php
$itemsPerPage = 50;
$page = 1;

$client = $this->get('highco.sphinx.client');
$client->SetLimits( ($page -1) * $itemsPerPage, $itemsPerPage);

$bridge = $this->get('highco.sphinx.pager.white_october.doctrine_orm');

/**
 * Make sure you have this column defined as attribute in Sphinx (i.e: sql_attr_string = type).
 * Sphinx prior version 1.10 does not have support for sql_attr_string, but you can use sql_attr_uint
 * and have your discriminators defined as constants in PHP.
 */
$bridge->setDiscriminatorColumn('type');

$bridge->setDiscriminatorRepositories(array(
    'article'       => array(
        'class' => 'BlogBundle:Article',
        'em'    => 'default',
    ),
    'category'      => array(
        'class' => 'BlogBundle:Category',
        'em'    => 'default',
    ),
    'note'         => array(
        'class' => 'NotesBundle:Message',
        'em'    => 'notes'
    ),
));

$bridge->setPkColumn('id');
$bridge->setSphinxResults($client->Query('Stéphane'));

$pager = $bridge->getPager();
$pager->setMaxPerPage($itemsPerPage);
$pager->setCurrentPage($page);

Todo

  • Watch for coding conventions, I....should be ....Interface, line should be wrapped, etc...
  • Let user can modify client options on config.yml
  • Create default pager, (*2)

  • Looking for doctrine FIELD extension, to be able to pass a DoctrineORMAdapter at PagerFanta !, (*3)

Whishlist

  • Provide other pager bridge

The Versions

16/07 2016

dev-master

9999999-dev https://github.com/Gemorroj/SphinxBundle

Sphinx search in Symfony

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jérémy Romey
by Avatar Gemorroj

search bundle symfony sphinx

16/07 2016

dev-refactoring

dev-refactoring https://github.com/Gemorroj/SphinxBundle

Sphinx search in Symfony

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jérémy Romey
by Avatar Gemorroj

search bundle symfony sphinx

16/07 2016

v2.0.0.x-dev

2.0.0.9999999-dev https://github.com/BLEUROY-HIGHCO/SphinxBundle

Sphinx search in Symfony

  Sources   Download

MIT

The Requires

 

by Jérémy Romey

search bundle symfony sphinx

10/03 2014

2.0.1

2.0.1.0 https://github.com/BLEUROY-HIGHCO/SphinxBundle

Sphinx search in Symfony

  Sources   Download

MIT

The Requires

 

by Jérémy Romey

search bundle symfony sphinx

20/11 2013

1.0.0

1.0.0.0 https://github.com/BLEUROY-HIGHCO/SphinxBundle

Sphinx search in Symfony

  Sources   Download

MIT

The Requires

 

by Jérémy Romey

search bundle symfony sphinx

20/11 2013

2.0.0

2.0.0.0 https://github.com/BLEUROY-HIGHCO/SphinxBundle

Sphinx search in Symfony

  Sources   Download

MIT

The Requires

 

by Jérémy Romey

search bundle symfony sphinx