1. Go to this page and download the library: Download digitlab/search-parser 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/ */
$parser = new SearchParser();
$filters = $parser->parse('string to parse');
[
'search' => 'string&to&parse'
]
class CustomSearchParser extends SearchParser
{
/**
* The filters that should be returned without handlers.
*
* @var array
*/
protected $passthruFilters = ['other'];
/**
* Handle the state filter.
*
* @param mixed $state
* @return array
*/
protected function handleState($state)
{
return ['some' => $state];
}
}
$parser = new CustomSearchParser();
$filters = $parser->parse('state:pending other:string string to parse');