PHP code example of elvenstar / statamic-typesense

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

    

elvenstar / statamic-typesense example snippets


    'drivers' => [
        
        // other drivers
        
        'typesense' => [
            'credentials' => [
                'api_key' => env('TYPESENSE_API_KEY', ''),
                'nodes' => [
                    'host' => env('TYPESENSE_URL', ''),
                ],
                'port' => env('TYPESENSE_PORT', '443'),
                'protocol' => env('TYPESENSE_PROTOCOL', 'https'),
                'nearest_node' => env('TYPESENSE_NEAREST_NODE', null),
                'connection_timeout' => env('TYPESENSE_TIMEOUT', 2),
            ],
        ],
    ],

    'schema' => [
        'articles' => [
            'fields' => [
                ['name' => 'synopsis', 'optional' => true],
                ['name' => 'category', 'facet' => true],
                ['name' => 'rating', 'type' => 'int32'],
                ['name' => 'published', 'type' => 'bool'],
                
            ],
            'default_sorting_field' => 'date',
        ],
    ],

    'default' => [
        'driver' => 'local',
        'searchables' => 'all',
        'fields' => ['title'],
    ],

php artisan vendor:publish --tag="statamic-typesense"