2017 © Pedro Peláez
 

library silex-algolia-provider

Algolia Silex service provider

image

phpextra/silex-algolia-provider

Algolia Silex service provider

  • Tuesday, January 5, 2016
  • by jkobus
  • Repository
  • 1 Watchers
  • 1 Stars
  • 292 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 6 % Grown

The README.md

This library integrates official Algolia client into Silex.
Algolia is a hosted Search API., (*1)

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

Installation

Installation is done using Composer:, (*2)

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):, (*3)

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

Author

The Versions

05/01 2016

dev-master

9999999-dev https://github.com/phpextra/silex-algolia-provider

Algolia Silex service provider

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Jacek Kobus