🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
Framework integration / Symfony / Getting started

Require the dependency (with Composer)

$
composer require algolia/search-bundle

Register the bundle

The bundle is registered automatically. If it does not register, add the following entry to config/bundles.php if you’re using Symfony 4.x.

1
2
3
4
5
6
return [
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    // ... Other bundles ...
    Algolia\SearchBundle\AlgoliaSearchBundle::class => ['all' => true],
];

If you’re using Symfony 3.4, add Algolia to your app/Kernel.php file:

1
2
3
4
5
$bundles = [
    new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
    // ... Other bundles ...
    new Algolia\SearchBundle\AlgoliaSearchBundle(),
];

Algolia credentials

You will also need to provide the Algolia App ID and Admin API key. By default, they are loaded from the ALGOLIA_APP_ID and ALGOLIA_API_KEY environment variables.

If you use .env config file, you can set them there.

1
2
ALGOLIA_APP_ID="YourApplicationID"
ALGOLIA_API_KEY="YourAPIKey"

If you don’t use environment variables, you can set your credentials in your parameters.yml file.

1
2
3
parameters:
    env(ALGOLIA_APP_ID): "YourApplicationID"
    env(ALGOLIA_API_KEY): "YourAPIKey"
Did you find this page helpful?