algolia / algolia-search-bundle
Installs: 291 857
Dependents: 2
Suggesters: 0
Security: 0
Stars: 189
Watchers: 82
Forks: 71
Open Issues: 20
Type:symfony-bundle
Requires
- php: >= 8.2
- algolia/algoliasearch-client-php: ^3.0
- doctrine/event-manager: ^1.1 || ^2.0
- doctrine/persistence: ^2.1 || ^3.0
- symfony/filesystem: ^7.0
- symfony/property-access: ^7.0
- symfony/serializer: ^7.0
Requires (Dev)
- ext-json: *
- doctrine/doctrine-bundle: ^2.12
- doctrine/orm: ^2.5
- friendsofphp/php-cs-fixer: ^v3.54.0
- friendsofphp/proxy-manager-lts: *
- jms/serializer-bundle: ^5.4.0
- phpunit/phpunit: ^8.5 || ^9.0
- roave/security-advisories: dev-master
- symfony/framework-bundle: ^7.0
- symfony/phpunit-bridge: ^7.0
- symfony/proxy-manager-bridge: *
- symfony/yaml: ^7.0
Conflicts
- doctrine/mongodb-odm: < 1.3
- 7.0.0
- 6.0.1
- 6.0.0
- dev-master / 5.x-dev
- 5.2.1
- 5.1.2
- 5.1.1
- 5.1.0
- 5.0.0
- 4.1.2
- 4.1.1
- 4.1.0
- 4.0.0
- 4.0.0-beta2
- 4.0.0-beta1
- 4.0.0-alpha3
- 4.0.0-alpha2
- 4.0.0-alpha1
- 3.x-dev
- 3.4.0
- 3.3.3
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.0
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.1
- 3.0.0
- 3.0.0-BETA5
- 3.0.0-BETA4
- 3.0.0-BETA3
- 3.0.0-BETA2
- 3.0.0-BETA
- 2.x-dev
- 2.3.0-beta
- 2.2.0
- 2.1.0
- 2.0.0
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-symfony-7-support
- dev-pr-380
- dev-ci-pr-trigger
- dev-fix/release
- dev-fix/aggregator-migration
- dev-chore/update-php-client
- dev-chore/update-composer
- dev-feat/formatted-exception
- dev-fix/serialize-once
This package is auto-updated.
Last update: 2024-07-15 12:57:28 UTC
README
The perfect starting point to integrate Algolia within your Symfony project
Documentation • PHP • Laravel • Community Forum • Stack Overflow • Report a bug • FAQ • Support
✨ Features
- Simple: You can get started with only 5 lines of YAML
- Robust: It benefits from all the new features of our PHP Client v2, like the
wait()
method - Flexible: All methods take optional
$requestOptions
to let you handle your data as you wish - Dev-friendly: Auto-completion and type-hinting thanks to an exhaustive documentation
Algolia SearchBundle supports PHP > 7.1
💡 Getting Started
First, install Algolia Search Bundle Integration via the composer package manager:
composer require algolia/search-bundle
You 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=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
If you don't use environment variables, you can set them in your parameters.yml
.
parameters: env(ALGOLIA_APP_ID): XXXXXXXXXX env(ALGOLIA_API_KEY): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Indexing data
First, 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 index
Example:
algolia_search: indices: - name: posts class: App\Entity\Post
Via CLI
Once 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,comments
Before re-indexing everything, you may want to clear the index first, see how to remove data.
Simple Search
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).
$em = $this->getDoctrine()->getManagerForClass(Post::class); $posts = $this->searchService->search($em, Post::class, 'query');
For full documentation, visit the Algolia Symfony Search Bundle.
Troubleshooting
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.
Use the Dockerfile
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.
📄 License
Algolia Symfony Search Bundle is an open-sourced software licensed under the MIT license.