PHP code example of locomotivemtl / charcoal-search

1. Go to this page and download the library: Download locomotivemtl/charcoal-search 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/ */

    

locomotivemtl / charcoal-search example snippets


use \Charcoal\Search\SearchRunner;

use \Foo\Bar\CustomObject;

$searchRunner = new SearchRunner([
    'search_config' => [
        'ident'    => 'my-custom-search',
        'searches' => [
            'foo'  => new CustomSearch([
                'logger'   => $logger
                'callback' => function($keyword) {

                }
            ])
        ]
    ],
    'model_factory' => $modelFactory,
    'logger'        => $logger
]);

// The results are an array like `['foo'=>[...], 'bar'=>[...]]`
$results = $searchRunner->search($keyword);

// Access log
$log = $searchRunner->searchLog();

// Differed access to results
$results = $searchRunner->results();