将Algolia Search无缝整合到你的Symfony项目中.
The perfect starting point to integrate Algolia within your Symfony project
Documentation • PHP • Laravel • Community Forum • Stack Overflow • Report a bug • FAQ • Support
$requestOptions to let you handle your data as you wishAlgolia SearchBundle requires PHP >= 8.2 and supports Symfony 7 and 8.
First, install Algolia Search Bundle Integration via the composer package manager:
composer require algolia/search-bundleYou will also need to provide the Algolia App ID and Admin API key. By default, they
are loaded from environment variables ALGOLIA_APP_ID and ALGOLIA_API_KEY.
If you use .env config file, you can set them there.
ALGOLIA_APP_ID=XXXXXXXXXX
ALGOLIA_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxIf you don't use environment variables, you can set them in your parameters.yml.
parameters:
env(ALGOLIA_APP_ID): XXXXXXXXXX
env(ALGOLIA_API_KEY): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxFirst, we need to define which entities should be indexed in Algolia.
Each entry under the indices config key must contain at least the 2 following attributes:
name is the canonical name of the index in Algoliaclass is the full name of the entity to indexExample:
algolia_search:
indices:
- name: posts
class: App\Entity\PostOnce your indices config is ready, you can use the built-in console command
to batch import all existing data.
# Import all indices
php bin/console search:import
# Choose what indices to reindex by passing the index name
php bin/console search:import --indices=posts,commentsBefore re-indexing everything, you may want to clear the index first, see how to remove data.
In this example we'll search for posts. The search method will query Algolia
to get matching results and then will create a doctrine collection. The data are
pulled from the database (that's why you need to pass the Doctrine Manager).
$posts = $this->searchService->search($entityManager, Post::class, 'query');For full documentation, visit the Algolia Symfony Search Bundle.
Encountering an issue? Before reaching out to support, we recommend heading to our FAQ where you will find answers for the most common issues and gotchas with the bundle.
If you want to contribute to this project without installing all its dependencies, you can use our Docker image. Please check our dedicated guide to learn more.
Algolia Symfony Search Bundle is an open-sourced software licensed under the MIT license.
暂无开放 Issues,或尚未同步最近议题。