SearchService
is your entry point for any operation with the Algolia engine:
- Index data
- Search
- Clear data
Retrieve the SearchService
Type-hinting
Symfony 4 ships with a lighter container, where only core services are registered. If your controller is responsible for search-related tasks, you can inject theSearchService
into the constructor by type-hinting the SearchServiceInterface
.
Symfony takes care of instantiating the right implementation for you.
PHP
Directly from the container
Symfony 3 uses a container holding all public services, and services are public by default. This way, you can get thesearch.service
from the container.
Note, that Symfony doesnβt consider this a best practice.
Instead, use type-hinting to retrieve the SearchService
.
PHP