PHP code example of yurunsoft / sphinx-client-swoole

1. Go to this page and download the library: Download yurunsoft/sphinx-client-swoole 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/ */

    

yurunsoft / sphinx-client-swoole example snippets


// 初始化连接池,改为你自己的连接配置
SphinxPool::init(5, '192.168.0.110', 9312);
// 连接池使用
SphinxPool::use(function($sphinxClient){
	// 改成你自己的搜索名和索引名
	$result = $sphinxClient->Query('query string', 'indexName');
		
	if($result)
	{
		var_dump($result['total']);
	}
	else
	{
		var_dump($sphinxClient->GetLastError());
	}
});

$client = new SphinxClient;
// 改为你自己的连接配置
$client->SetServer('192.168.0.110', 9312);
// 改成你自己的搜索名和索引名
var_dump($client->Query('query string', 'indexName'));