PHP code example of ergnuor / sphinx-config
1. Go to this page and download the library: Download ergnuor/sphinx-config 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/ */
ergnuor / sphinx-config example snippets
#!/usr/bin/php
// generated by composer --dump-autoload
oNativeConfigStdout('/path/to/config/source');
$config ->transform('preciousConfig');
//...
use Ergnuor\SphinxConfig\Config;
$config = Config::phpArrayToNativeConfigFile(
'/path/to/config/source',
'/path/to/sphinx/config'
);
$config->transform('preciousConfig');
exec('searchd -c /path/to/sphinnx/config/presiousConfig.conf');
//...
return [
'source' => [
'main' => [
'sql_query_pre' => [
'SET NAMES utf8',
'SET CHARACTER SET utf8'
],
// ... all other setting
],
],
'index' => [
'main' => [
'source' => 'main',
'path' => '/path/to/main',
// ... all other setting
],
],
'indexer' => [
'mem_limit' => '1024M',
// ... all other setting
],
'searchd' => [
'listen' => 'localhost:9306:mysql41',
// ... all other setting
],
'common' => [
'lemmatizer_base' => '/usr/local/share/sphinx/dicts/',
// ... all other setting
],
];
return [
'source' => [
'main' => [
// ... other block settings
],
'delta' => [
'extends' => 'main',
// ... pther block settings
]
],
];
'sql_query_pre:clear' => [
'SET NAMES utf8',
// ... other pre queries
],
return [
'source' => [
'main' => [
'sql_query_pre' => [
'SET NAMES utf8',
// ... other pre queries
'sph_counter' => 'INSERT INTO sphCounter (indexingStartedAt, caption)
VALUES(NOW(), \'main\')
ON DUPLICATE KEY UPDATE indexingStartedAt = now()'
],
// ... other block settings
],
'delta' => [
'extends' => 'main',
'sql_query_pre' => [
'sph_counter' => 'INSERT INTO sphCounter (indexingStartedAt, caption)
VALUES(NOW(), \'delta\')
ON DUPLICATE KEY UPDATE indexingStartedAt = now()'
],
// ... other block settings
]
],
];
return [
'source' => [
'main' => [
'sql_query_pre' => [
'SET NAMES utf8',
// ... other queries
'INSERT INTO sphCounter (indexingStartedAt, caption)
VALUES(NOW(), \'::sourceName::\')
ON DUPLICATE KEY UPDATE indexingStartedAt = now()'
],
'placeholderValues' => [
'sourceName' => 'main',
],
// ... other block settings
],
'delta' => [
'extends' => 'main',
'placeholderValues' => [
'sourceName' => 'delta',
],
// ... other block settings
]
],
];