PHP code example of miroshnichenko-yaroslav / laravel-algolia

1. Go to this page and download the library: Download miroshnichenko-yaroslav/laravel-algolia 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/ */

    

miroshnichenko-yaroslav / laravel-algolia example snippets


// Search.
$algolia->search('marty mcfly');

// Create global API keys.
$algolia->addUserKey(['search'], 300);

// Want to use the facade?
Algolia::getLogs();

Vinkla\Algolia\AlgoliaServiceProvider::class

'Algolia' => Vinkla\Algolia\Facades\Algolia::class

// You can alias this in config/app.php.
use Vinkla\Algolia\Facades\Algolia;

Algolia::initIndex('contacts');
// We're done here - how easy was that, it just works!

Algolia::getLogs();
// This example is simple and there are far more methods available.

use Vinkla\Algolia\Facades\Algolia;

// Writing this…
Algolia::connection('main')->initIndex('contacts');

// …is identical to writing this
Algolia::initIndex('contacts');

// and is also identical to writing this.
Algolia::connection()->initIndex('contacts');

// This is because the main connection is configured to be the default.
Algolia::getDefaultConnection(); // This will return main.

// We can change the default connection.
Algolia::setDefaultConnection('alternative'); // The default is now alternative.

use Vinkla\Algolia\AlgoliaManager;

class Foo
{
	protected $algolia;

	public function __construct(AlgoliaManager $algolia)
	{
		$this->algolia = $algolia;
	}

	public function bar()
	{
		$this->algolia->initIndex('friends');
	}
}

App::make('Foo')->bar();
bash
$ php artisan vendor:publish