diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index d01c2583..de190717 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -146,7 +146,7 @@ _[Read more about this](https://github.com/meilisearch/integration-guides/blob/m
Make a PR modifying the file [`src/MeiliSearchBundle.php`](/src/MeiliSearchBundle.php) with the right version.
-```ruby
+```php
VERSION = 'X.X.X'
```
diff --git a/composer.json b/composer.json
index 3ab58cae..a2493f21 100644
--- a/composer.json
+++ b/composer.json
@@ -1,69 +1,70 @@
{
- "name": "meilisearch/search-bundle",
- "description": "Seamless integration of Meilisearch into your Symfony project.",
- "keywords": [
- "meilisearch",
- "instant",
- "search",
- "api",
- "symfony",
- "bundle"
- ],
- "type": "symfony-bundle",
- "license": "MIT",
- "authors": [
- {
- "name": "David Sanchez",
- "email": "david38sanchez@gmail.com"
- }
- ],
- "require": {
- "php": "^7.4|^8.0",
- "ext-json": "*",
- "doctrine/doctrine-bundle": "^2.4",
- "illuminate/collections": "^8.47",
- "meilisearch/meilisearch-php": "^0.24.0",
- "symfony/filesystem": "^4.4 || ^5.0 || ^6.0",
- "symfony/property-access": "^4.4 || ^5.0 || ^6.0",
- "symfony/serializer": "^4.4 || ^5.0 || ^6.0"
- },
- "require-dev": {
- "doctrine/orm": "^2.9",
- "friendsofphp/php-cs-fixer": "^3.0",
- "nyholm/psr7": "^1.3",
- "phpstan/extension-installer": "^1.1",
- "phpstan/phpstan": "^0.12.90",
- "phpstan/phpstan-doctrine": "^0.12.39",
- "phpstan/phpstan-phpunit": "^0.12.20",
- "phpstan/phpstan-symfony": "^0.12.37",
- "phpunit/php-code-coverage": "^9.2",
- "phpunit/phpunit": "^9.5",
- "symfony/doctrine-bridge": "^4.4 || ^5.0 || ^6.0",
- "symfony/http-client": "^4.4 || ^5.0 || ^6.0",
- "symfony/phpunit-bridge": "^4.4 || ^5.0 || ^6.0",
- "symfony/yaml": "^4.4 || ^5.0 || ^6.0"
- },
- "autoload": {
- "psr-4": {
- "MeiliSearch\\Bundle\\": "src/"
- }
- },
- "autoload-dev": {
- "psr-4": {
- "MeiliSearch\\Bundle\\Test\\": "tests/"
- }
- },
- "config": {
- "sort-packages": true,
- "allow-plugins": {
- "phpstan/extension-installer": true
- }
- },
- "scripts": {
- "phpstan": "./vendor/bin/phpstan --memory-limit=1G --ansi",
- "test:unit": "./vendor/bin/phpunit --colors=always --verbose",
- "test:unit:coverage": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --colors=always --coverage-html=tests/coverage",
- "lint:check": "./vendor/bin/php-cs-fixer fix -v --using-cache=no --dry-run",
- "lint:fix": "./vendor/bin/php-cs-fixer fix -v --using-cache=no"
+ "name": "meilisearch/search-bundle",
+ "description": "Seamless integration of Meilisearch into your Symfony project.",
+ "keywords": [
+ "meilisearch",
+ "instant",
+ "search",
+ "api",
+ "symfony",
+ "bundle"
+ ],
+ "type": "symfony-bundle",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "David Sanchez",
+ "email": "david38sanchez@gmail.com"
}
+ ],
+ "require": {
+ "php": "^7.4|^8.0",
+ "ext-json": "*",
+ "doctrine/doctrine-bundle": "^2.4",
+ "illuminate/collections": "^8.47",
+ "meilisearch/meilisearch-php": "^0.24.2",
+ "symfony/filesystem": "^4.4 || ^5.0 || ^6.0",
+ "symfony/property-access": "^4.4 || ^5.0 || ^6.0",
+ "symfony/serializer": "^4.4 || ^5.0 || ^6.0"
+ },
+ "require-dev": {
+ "doctrine/orm": "^2.9",
+ "friendsofphp/php-cs-fixer": "^3.0",
+ "nyholm/psr7": "^1.3",
+ "phpstan/extension-installer": "^1.1",
+ "phpstan/phpstan": "^0.12.90",
+ "phpstan/phpstan-doctrine": "^0.12.39",
+ "phpstan/phpstan-phpunit": "^0.12.20",
+ "phpstan/phpstan-symfony": "^0.12.37",
+ "phpunit/php-code-coverage": "^9.2",
+ "phpunit/phpunit": "^9.5",
+ "symfony/doctrine-bridge": "^4.4 || ^5.0 || ^6.0",
+ "symfony/http-client": "^4.4 || ^5.0 || ^6.0",
+ "symfony/phpunit-bridge": "^4.4 || ^5.0 || ^6.0",
+ "symfony/yaml": "^4.4 || ^5.0 || ^6.0",
+ "matthiasnoback/symfony-dependency-injection-test": "^4.3"
+ },
+ "autoload": {
+ "psr-4": {
+ "MeiliSearch\\Bundle\\": "src/"
+ }
+ },
+ "autoload-dev": {
+ "psr-4": {
+ "MeiliSearch\\Bundle\\Test\\": "tests/"
+ }
+ },
+ "config": {
+ "sort-packages": true,
+ "allow-plugins": {
+ "phpstan/extension-installer": true
+ }
+ },
+ "scripts": {
+ "phpstan": "./vendor/bin/phpstan --memory-limit=1G --ansi",
+ "test:unit": "./vendor/bin/phpunit --colors=always --verbose",
+ "test:unit:coverage": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --colors=always --coverage-html=tests/coverage",
+ "lint:check": "./vendor/bin/php-cs-fixer fix -v --using-cache=no --dry-run",
+ "lint:fix": "./vendor/bin/php-cs-fixer fix -v --using-cache=no"
+ }
}
diff --git a/src/DependencyInjection/MeiliSearchExtension.php b/src/DependencyInjection/MeiliSearchExtension.php
index cf95a547..96e30062 100644
--- a/src/DependencyInjection/MeiliSearchExtension.php
+++ b/src/DependencyInjection/MeiliSearchExtension.php
@@ -5,6 +5,7 @@
namespace MeiliSearch\Bundle\DependencyInjection;
use MeiliSearch\Bundle\Engine;
+use MeiliSearch\Bundle\MeiliSearchBundle;
use MeiliSearch\Bundle\Services\MeiliSearchService;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -29,12 +30,13 @@ public function load(array $configs, ContainerBuilder $container): void
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
- if (null === $config['prefix']) {
+ if (null === $config['prefix'] && $container->hasParameter('kernel.environment')) {
$config['prefix'] = $container->getParameter('kernel.environment').'_';
}
- $container->setParameter('meili_url', $config['url']);
- $container->setParameter('meili_api_key', $config['api_key']);
+ $container->setParameter('meili_url', $config['url'] ?? null);
+ $container->setParameter('meili_api_key', $config['api_key'] ?? null);
+ $container->setParameter('meili_symfony_version', MeiliSearchBundle::qualifiedVersion());
if (\count($doctrineSubscribedEvents = $config['doctrineSubscribedEvents']) > 0) {
$container->getDefinition('search.search_indexer_subscriber')->setArgument(1, $doctrineSubscribedEvents);
diff --git a/src/MeiliSearchBundle.php b/src/MeiliSearchBundle.php
index 92dfeb70..fb55091d 100644
--- a/src/MeiliSearchBundle.php
+++ b/src/MeiliSearchBundle.php
@@ -12,4 +12,9 @@
final class MeiliSearchBundle extends Bundle
{
public const VERSION = '0.8.0';
+
+ public static function qualifiedVersion()
+ {
+ return sprintf('Meilisearch Symfony (v%s)', MeiliSearchBundle::VERSION);
+ }
}
diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml
index 00f241ef..2bd3bac2 100644
--- a/src/Resources/config/services.xml
+++ b/src/Resources/config/services.xml
@@ -21,6 +21,9 @@
%meili_url%
%meili_api_key%
+
+ %meili_symfony_version%
+
diff --git a/tests/Integration/DependencyInjectionTest.php b/tests/Integration/DependencyInjectionTest.php
new file mode 100644
index 00000000..c04a898e
--- /dev/null
+++ b/tests/Integration/DependencyInjectionTest.php
@@ -0,0 +1,31 @@
+load();
+
+ $this->assertContainerBuilderHasServiceDefinitionWithArgument('search.client', '$clientAgents', ['%meili_symfony_version%']);
+ }
+
+ public function testHasMeilisearchVersionFromConstantAfterLoad(): void
+ {
+ $this->load();
+
+ $this->assertContainerBuilderHasParameter('meili_symfony_version', MeiliSearchBundle::qualifiedVersion());
+ }
+}