Skip to main content
Use the SearchService to index, search, and manage data with Algolia.

Inject the SearchService using type hints

To use search in a controller or service, inject the SearchService into the constructor. Symfonyโ€™s container autowires the concrete implementation for you.
PHP
namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Algolia\SearchBundle\SearchService;

class ExampleController extends AbstractController
{
    protected $searchService;

    public function __construct(SearchService $searchService)
    {
        $this->searchService = $searchService;
    }
}
Last modified on April 27, 2026