PHP code example of maxchene / kirby3-typesense

1. Go to this page and download the library: Download maxchene/kirby3-typesense 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/ */

    

maxchene / kirby3-typesense example snippets


'maxchene.typesense' => [
        'host' => 'localhost:8108', # typesense host and port
        'key' => 'secret', # typesense API key
        'num_typos' => 2, # number of allowed typo error
        'schema' => [
            'name' => 'my-collection',
            'fields' => [
                ['name' => 'content', 'type' => 'string'],
                ['name' => 'type', 'type' => 'string']
            ]
        ],
        'templates' => [
            'article' => function (Page $page) {

            },
            'default' => function (Page $page) {
                return [
                    'content' => 'text content that should be indexed for fulltext search',
                    'type' => 'default'
                ];
            }
        ]
    ]

 $searchEngine = new TypesenseSearch();
 $results =  $searchEngine->search($query, $limit, $page);

site/config/config.php