Symfony : Do not know how to display algolia searchbar

I followed the algolia guide on how to implement a searchbar on a symfony project. https://www.algolia.com/doc/framework-integration/symfony/getting-started/algolia-searchbundle/?language=php

What I’ve done ?

  • installed algolia bundle with composer require algolia/search-bundle:4.0.0
  • enable bundle in bundles.php
  • added API ID and API KEY in .env
  • configured config/packages/algolia_search.yaml with my indices
  • added * @Groups({"searchable"}) on my concerned attributes imported my
  • imported my indices with bin/console search:import;
  • configured my indices on the dashboard
  • made a controller based on the guide and on the github (not sure about that one)

Here’s my SearchController :

namespace AppController;

use AppEntityIdea;
use AlgoliaSearchBundleSearchService;
use SymfonyComponentHttpFoundationRequest;
use AlgoliaSearchBundleResponsesSearchServiceResponse;
use SymfonyBundleFrameworkBundleControllerAbstractController;

class SearchController extends AbstractController
{

    /*protected $searchService;
    public function __construct(SearchServiceInterface $searchService)
    {
        $this->searchService = $searchService;
    } */


    public function search(Request $request) {

        $em = $this->getDoctrine()->getManagerForClass(Idea::class);
        $posts = $this->searchService->search($em, Idea::class, 'query');
    }
}

So now, I have no idea how to display the searchbar and make it effective ?
Can someone guide me with those steps ?

Ps : I use twig templates

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *