1. Go to this page and download the library: Download olegpro/bitrix-sphinx library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
olegpro / bitrix-sphinx example snippets
use Bitrix\Main;
use Bitrix\Main\Localization\Loc;
use Olegpro\BitrixSphinx\Entity\SphinxDataManager;
use Olegpro\BitrixSphinx\Entity\SphinxQuery;
Loc::loadMessages(__FILE__);
class SampleTable extends SphinxDataManager
{
/**
* Returns index sphinx name for entity.
*
* @return string
*/
public static function getTableName()
{
return 'sample_index';
}
/**
* Returns sphinx-connection name for entity
*
* @return string
*/
public static function getConnectionName()
{
return 'sphinx';
}
/**
* Creates and returns the Query object for the entity
*
* @return SphinxQuery
*/
public static function query()
{
return new SphinxQuery(static::getEntity());
}
/**
* Returns entity map definition.
*
* @return array
*/
public static function getMap()
{
return [
new Main\Entity\IntegerField('id', [
'primary' => true,
]),
new Main\Entity\StringField('name'),
new Main\Entity\BooleanField('available', [
'values' => [0, 1],
])
];
}
}