All Projects → liip → LiipSearchBundle

liip / LiipSearchBundle

Licence: other
[DEPRECATED] Google XML API for searching is discontinued

Programming Languages

PHP
23972 projects - #3 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to LiipSearchBundle

Liiphellobundle
[DEPRECATED] Alternative Hello World Bundle for Symfony2 using several FriendsOfSymfony Bundles
Stars: ✭ 206 (+488.57%)
Mutual labels:  bundle, symfony-bundle
SonataTimelineBundle
[Abandoned] Integrates SpyTimelineBundle into Sonata
Stars: ✭ 24 (-31.43%)
Mutual labels:  bundle, symfony-bundle
Sonataadminbundle
The missing Symfony Admin Generator
Stars: ✭ 2,039 (+5725.71%)
Mutual labels:  bundle, symfony-bundle
Debug Bundle
The DebugBundle allows greater integration of the VarDumper component in the Symfony full-stack framework.
Stars: ✭ 2,033 (+5708.57%)
Mutual labels:  bundle, symfony-bundle
gulp-rev-versions-bundle
A bundle that allows symfony to get the version of assets versioned with gulp-rev
Stars: ✭ 13 (-62.86%)
Mutual labels:  bundle, symfony-bundle
Nelmioapidocbundle
Generates documentation for your REST API from annotations
Stars: ✭ 2,009 (+5640%)
Mutual labels:  bundle, symfony-bundle
Gifexceptionbundle
😛 The GhostBuster of your exception page!
Stars: ✭ 197 (+462.86%)
Mutual labels:  bundle, symfony-bundle
Web Profiler Bundle
The WebProfilerBundle provides detailed technical information about each request execution and displays it in both the web debug toolbar and the profiler.
Stars: ✭ 1,905 (+5342.86%)
Mutual labels:  bundle, symfony-bundle
Enqueue Bundle
[READ-ONLY] Message queue bundle for Symfony. RabbitMQ, Amazon SQS, Redis, Service bus, Async events, RPC over MQ and a lot more
Stars: ✭ 233 (+565.71%)
Mutual labels:  bundle, symfony-bundle
Mercure Bundle
The MercureBundle allows to easily push updates to web browsers and other HTTP clients in the Symfony full-stack framework, using the Mercure protocol.
Stars: ✭ 195 (+457.14%)
Mutual labels:  bundle, symfony-bundle
Victoire
Fullstack Symfony CMS: The perfect mix between a framework and a CMS
Stars: ✭ 227 (+548.57%)
Mutual labels:  bundle, symfony-bundle
Fmelfinderbundle
📁 ElFinderBundle provides ElFinder integration with TinyMCE, CKEditor, Summernote editors
Stars: ✭ 231 (+560%)
Mutual labels:  bundle, symfony-bundle
Craueconfigbundle
Database-stored settings made available via a service for your Symfony project.
Stars: ✭ 154 (+340%)
Mutual labels:  bundle, symfony-bundle
Sonataintlbundle
Symfony SonataIntlBundle
Stars: ✭ 212 (+505.71%)
Mutual labels:  bundle, symfony-bundle
Sonatanewsbundle
Symfony SonataNewsBundle
Stars: ✭ 153 (+337.14%)
Mutual labels:  bundle, symfony-bundle
Twig Bundle
The Twig Bundle provides configuration for using Twig in your applications.
Stars: ✭ 2,150 (+6042.86%)
Mutual labels:  bundle, symfony-bundle
Sonatanotificationbundle
Symfony SonataNotificationBundle
Stars: ✭ 136 (+288.57%)
Mutual labels:  bundle, symfony-bundle
Consolebundle
Commandline interface in browser for Symfony2
Stars: ✭ 138 (+294.29%)
Mutual labels:  bundle, symfony-bundle
Sonatapagebundle
This bundle provides a Site and Page management through container and block services
Stars: ✭ 181 (+417.14%)
Mutual labels:  bundle, symfony-bundle
Lexikmaintenancebundle
This Symfony2 bundle allows you to place your website in maintenance mode by calling two commands in your console. A page with status code 503 appears to users, it is possible to authorize certain ips addresses stored in your configuration.
Stars: ✭ 253 (+622.86%)
Mutual labels:  bundle, symfony-bundle

LiipSearchBundle

Latest Stable Version Latest Unstable Version Total Downloads

This bundle provides a uniform interface for full text search with various search engines and a controller with twig templates to render search forms and results.

Note: You are looking at Version 2 of this bundle, which saw large changes compared to Version 1.

Introduction

This search bundle simplifies adding search to your site.

Provided for you are:

  • A controller to render a search box and the search page with twig templates
  • A service to query google site search
  • A service which provides paging for the search results

Built-in Search Engines Support

For now, Google site search is supported out of the box. There is one implementation using the Google REST API and one implementation using the Custom Search Element feature that loads the search with only javascript in the frontend.

Contributions for other services are welcome.

Installation

Install the bundle with composer require liip/search-bundle.

Include the bundle in app/Kernel.php.

Add your preferred search engine in app/config/config.yml:

liip_search:
    clients:
        google_rest:
            api_key: '%google.api_key%'
            search_key: '%google.search_key%'

Or if you use the javascript Google custom search engine:

liip_search:
    clients:
        google_cse:
            cse_id: '%google.search_key%'

Usage

You can display a search box anywhere on the page with the liip_search_box twig function:

{{ liip_search_box(query, 'query-field-id', 'css-class') }}

You can customize the search box with these parameters:

  • query - default query to display
  • fieldId - HTML id to use for the search input field. Use different ids when having more than one search box on your page, e.g. in the header and in content.
  • cssClass - A css class to apply to the whole search box <form>.

Create a route for the search action. The easiest is to just use the provided routing.xml from your main project routing.xml:

    liip_search:
        resource: "@LiipSearchBundle/Resources/config/routing.xml"

It defaults to the URL /search. If you want a different route, use the prefix option when including the route or configure your own route using %liip_search.controller.search_action% as default value for _controller.

Customizing Templating

The search result templates provided by this bundle extend the LiipSearchBundle::layout.html.twig template. To integrate with the rest of your site, you have two options:

  • Create app/Resources/LiipSearchBundle/views/layout.html.twig and make it extend your base layout, putting a liip_search_content block where you want the search results.
  • Create app/Resources/LiipSearchBundle/views/Search/search.html.twig and build your own templating structure - you should be able to use the search_results.twig.html template to get the liip_search_content block.

Of course you can also override any of the templates to customize what they should do. See http://symfony.com/doc/master/book/templating.html#overriding-bundle-templates

Configuration Reference

This is the full reference of what you can configure under the liip_search key:

search_factory

string, default value: null

Specify a custom service that implements the Liip\SearchBundle\SearchFactoryInterface. This service will be used by the controller to create Pagerfanta instances to handle the search.

If you configure one of the search engine services, you do not need to set this field.

search_route

string, default value: liip_search

The name of the route that will handle submitted search requests.

restrict_language

boolean, default value: false

Change this to true if you want to ask the search service to restrict the results to the language of the request.

Google Search REST API Integration

Configuring any of these options enables the google search engine service. They are located under clients.google_rest.

api_key

string, required

Your Google API key

search_key

string|array, required

The key identifying your Google Search Engine. May be a list of keys indexed by locale to use different engines per locale. If you control locales through separate search engines, you do not need to set restrict_language to true unless you want your custom search engines to receive a language restriction additionally.

api_url

string, default value: https://www.googleapis.com/customsearch/v1

The Google Search API URL for REST calls

restrict_to_site

string, default value: null

If left empty, all sites configured for the google search engines are searched. Set to a a domain to limit to that domain.

Google Custom Search Engine Integration

Configuring this section activates a different controller that renders the Javascript fragment to enable the CSE search. This configuration is located under clients.google_cse.

cse_id

string|array, required

The key identifying your Google Custom Search Engine. May be a list of keys indexed by locale to use different engines per locale. CSE does not support the restrict_language, so different search engines per language are your only option to restrict the language of search results.

Troubleshooting

Google Custom Search Engine

If you get SearchException saying "Empty response received from Google Search Engine API", try copying the URL that is output into a browser. You should get JSON response, but likely it will haves an error status.

If you get a status 500 with an empty message, chances are that you need to renew the search engine in the Google admin panel.

Adding your own Search Service

Implement the Liip\SearchBundle\SearchInterface and configure it as a service. Then set liip_search.search_client to that service name.

TODO

  • Use guzzle to talk to google REST API
  • Add support for refinements (more like this) with info in search result array that can be passed to SearchInterface::refineSearch
  • Expose more of the google search parameters
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].