Skip to content
This repository has been archived by the owner on Nov 21, 2017. It is now read-only.

phpextra/silex-algolia-provider

Repository files navigation

#Silex Service Provider for Algolia Search

This library integrates official Algolia client into Silex.
Algolia is a hosted Search API.

  1. Installation
  2. Usage
    1. Service registration
    2. Using provided trait
  3. Useful links
  4. Author

##Installation

Installation is done using Composer:

composer require phpextra/silex-algolia-provider

You can test the library using phpunit by running the following command (assuming that you have phpunit command available):

phpunit ./tests

##Usage

###Service registration:

$app = new Application();
$app->register(new AlgoliaSearchServiceProvider());

$app['algolia.application_id'] = 'dummy';
$app['algolia.api_key'] = 'dummy';
$app['algolia.index.name'] = 'dummy';

/* ... */

$app->get(function(Request $request) use ($app){
    return new JsonResponse($app['algolia.index']->search($request->get('q')));
});

###Using provided trait:

class MyApplication extends Application 
{
    use AlgoliaSearchTrait;
    
    public function __construct()
    {
        $this->register(new AlgoliaSearchServiceProvider());
        parent::__construct();
    }
}

$app = new MyApplication();

/* ... */

$app->algolia(); // gives you access to Algolia Client instance
$app->search('query'); // performs search

##Useful links

##Author

About

Integrates Algolia Search client into Silex

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages