PHP code example of imarc / craft-googlecustomsearch

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

    

imarc / craft-googlecustomsearch example snippets



return [
    'siteSettings' => [
        // Google Custom Search
        'default' => [
            'provider' => 'gcs',
            'apiKey' => getenv('GOOGLE_SEARCH_API_KEY'),
            'searchEngineId' => getenv('GOOGLE_SEARCH_ENGINE_ID'),
        ],
        // Google Vertex AI Search
        'fr' => [
            'provider' => 'vertex',
            'projectId' => getenv('GOOGLE_CLOUD_PROJECT'),
            'location' => 'global',
            'engineId' => getenv('VERTEX_SEARCH_ENGINE_ID'),
            'serviceAccountFile' => getenv('GOOGLE_APPLICATION_CREDENTIALS'),
        ],
        // AddSearch
        'de' => [
            'provider' => 'addsearch',
            'siteKey' => getenv('ADDSEARCH_SITE_KEY'),
            'addsearchApiKey' => getenv('ADDSEARCH_API_KEY'), // optional, private indices only
        ],
    ],
];