PHPackages                             liip/search-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. liip/search-bundle

AbandonedArchivedSymfony-bundle[Search &amp; Filtering](/categories/search)

liip/search-bundle
==================

This bundles provides some basic infrastructure for creating a search UI in Symfony2 applications along with integration with Google's search API

2.0.0(10y ago)3680.0k10[3 issues](https://github.com/liip/LiipSearchBundle/issues)[2 PRs](https://github.com/liip/LiipSearchBundle/pulls)1MITPHPPHP ^5.3.9|^7.0

Since Jun 11Pushed 8y ago17 watchersCompare

[ Source](https://github.com/liip/LiipSearchBundle)[ Packagist](https://packagist.org/packages/liip/search-bundle)[ RSS](/packages/liip-search-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (7)Dependencies (2)Versions (12)Used By (1)

LiipSearchBundle
================

[](#liipsearchbundle)

[![Latest Stable Version](https://camo.githubusercontent.com/1d70e70506cc00c719f821c5774a8c690744cd2188b4420239b9a3e215d9de78/68747470733a2f2f706f7365722e707567782e6f72672f6c6969702f7365617263682d62756e646c652f762f737461626c652e737667)](https://packagist.org/packages/liip/search-bundle)[![Latest Unstable Version](https://camo.githubusercontent.com/4298dfaede52cdda58d339b95268e8137378dab73206a236684893deaa245ebb/68747470733a2f2f706f7365722e707567782e6f72672f6c6969702f7365617263682d62756e646c652f762f756e737461626c652e737667)](https://packagist.org/packages/liip/search-bundle)[![Total Downloads](https://camo.githubusercontent.com/1e3b8402f37076dae7b22b69925f821049ae4a1f3814b3e91964d0b94c446729/68747470733a2f2f706f7365722e707567782e6f72672f6c6969702f7365617263682d62756e646c652f642f746f74616c2e706e67)](https://packagist.org/packages/liip/search-bundle)

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](https://github.com/liip/LiipSearchBundle/tree/1.0).

Introduction
------------

[](#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

[](#built-in-search-engines-support)

For now, [Google site search](http://www.google.com/sitesearch/) is supported out of the box. There is one implementation using the [Google REST API](https://developers.google.com/custom-search/json-api/v1/overview)and one implementation using the [Custom Search Element](https://developers.google.com/custom-search/docs/element)feature that loads the search with only javascript in the frontend.

Contributions for other services are welcome.

Installation
------------

[](#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
-----

[](#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 ``.

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

[](#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

Configuration Reference
-----------------------

[](#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

[](#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](https://code.google.com/apis/console)

`search_key`

**string|array**, required

The key identifying your [Google Search Engine](https://www.google.com/cse). 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:

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

[](#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](https://www.google.com/cse). 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
---------------

[](#troubleshooting)

### Google Custom Search Engine

[](#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](https://www.google.com/cse/all).

Adding your own Search Service
------------------------------

[](#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
----

[](#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

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community27

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~118 days

Recently: every ~83 days

Total

10

Last Release

3708d ago

Major Versions

1.0.1 → 2.0.0-alpha12015-02-05

1.0.x-dev → 2.0.0-beta22015-10-26

PHP version history (3 changes)1.0.0PHP &gt;=5.3.0

1.0.1PHP &gt;=5.3.3

2.0.0-beta2PHP ^5.3.9|^7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/76576?v=4)[David Buchmann](/maintainers/dbu)[@dbu](https://github.com/dbu)

![](https://avatars.githubusercontent.com/u/20873?v=4)[Luke Smith](/maintainers/lsmith)[@lsmith](https://github.com/lsmith)

---

Top Contributors

[![lsmith77](https://avatars.githubusercontent.com/u/300279?v=4)](https://github.com/lsmith77 "lsmith77 (26 commits)")[![dbu](https://avatars.githubusercontent.com/u/76576?v=4)](https://github.com/dbu "dbu (21 commits)")[![brki](https://avatars.githubusercontent.com/u/697240?v=4)](https://github.com/brki "brki (12 commits)")[![penfold45](https://avatars.githubusercontent.com/u/1208629?v=4)](https://github.com/penfold45 "penfold45 (1 commits)")[![ralf57](https://avatars.githubusercontent.com/u/208237?v=4)](https://github.com/ralf57 "ralf57 (1 commits)")[![thePanz](https://avatars.githubusercontent.com/u/226021?v=4)](https://github.com/thePanz "thePanz (1 commits)")[![0x616469](https://avatars.githubusercontent.com/u/522627?v=4)](https://github.com/0x616469 "0x616469 (1 commits)")[![vpowler](https://avatars.githubusercontent.com/u/9549416?v=4)](https://github.com/vpowler "vpowler (1 commits)")[![bocharsky-bw](https://avatars.githubusercontent.com/u/3317635?v=4)](https://github.com/bocharsky-bw "bocharsky-bw (1 commits)")[![gperriard](https://avatars.githubusercontent.com/u/1012526?v=4)](https://github.com/gperriard "gperriard (1 commits)")

---

Tags

bundlephpsearchsymfonysymfony-bundleSymfony2

### Embed Badge

![Health badge](/badges/liip-search-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/liip-search-bundle/health.svg)](https://phpackages.com/packages/liip-search-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)[ddmaster/postgre-search-bundle

Tools to use full-text search PostgreSQL in Doctrine.

1391.6k](/packages/ddmaster-postgre-search-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
