PHP code example of ermakove / laravel-manticoresearch

1. Go to this page and download the library: Download ermakove/laravel-manticoresearch 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/ */

    

ermakove / laravel-manticoresearch example snippets


// Enable shortname of facade
$app->withFacades(true, [
    'ManticoreSearch\Laravel\Facade' => 'Facade',
]);

// Register Config Files
$app->configure('manticoresearch');

// Register Service Providers
$app->register(ManticoreSearch\Laravel\ServiceProvider::class);



$config = ['host'=>'127.0.0.1', 'port'=>9308];
$client = new \Manticoresearch\Client($config);
$index  = new \Manticoresearch\Index($client);
$index->setName('movies'); 

$index = \ManticoreSearch::index('movies');

$index   = \ManticoreSearch::connection('connectionName')->index($nameOfIndex);
$pq      = \ManticoreSearch::connection('connectionName')->pq();
$cluster = \ManticoreSearch::connection('connectionName')->cluster();
$indices = \ManticoreSearch::connection('connectionName')->indices();
$nodes   = \ManticoreSearch::connection('connectionName')->nodes();

// etc...

\ManticoreSearch::connection('connectionName')->sql($params);
\ManticoreSearch::connection('connectionName')->replace($params);
\ManticoreSearch::connection('connectionName')->delete($params);

// etc...

// using injection:
public function handle(\ManticoreSearch\Laravel\Manager $manticoresearch)
{
    $manticoresearch->describe();
}

// using application container:
$manticoreSearch = $this->app('manticoresearch');

$logger = new \Monolog\Logger('name');
$logger->pushHandler(new \Monolog\Handler\StreamHandler('/my/log.file', Logger::INFO));
$config = ['host' => '127.0.0.1', 'port' => 9306];
$client = new \Manticoresearch\Client($config, $logger);
$index  = new \Manticoresearch\Index($client);
$index->setName('movies');

$logger = new \Monolog\Logger('name');
$logger->pushHandler(new \Monolog\Handler\StreamHandler('/my/log.file', Logger::INFO));

$index = \ManticoreSearch::connection('connectionName', $logger)->index('movies');
sh
php artisan vendor:publish --provider="ManticoreSearch\Laravel\ServiceProvider"