diff --git a/README.md b/README.md index b435de9..0747a2e 100644 --- a/README.md +++ b/README.md @@ -91,15 +91,22 @@ DATABASE_URL=mysql://foo:bar@host:3306 The default Solr connection can be configured via a [DSN](https://en.wikipedia.org/wiki/Data_source_name): ```dotenv -SOLR_URL=host:port +SOLR_URL=http://localhost ``` -For example: +This package makes several assumptions, which can be overridden via the `SOLR_URL` DSN. The DSN in the +example above is automatically expanded to: ```dotenv -SOLR_URL=solr.foo.site:8983 +SOLR_URL=http://default@localhost:8983#default ``` +In the expanded example above, the `user` is the name of the Solr core & the `fragment` is the Drupal machine +name for the connection. Consider revising Solr core & Drupal Solr server machine names to `default`, +so the shorter DSN can be used. + +Streamlined environment-dependent configuration of _one_ Solr core is supported at this time. + ##### Supported Placeholders * `{{app_path}}`: The path where Drupal is located. * `{{project_path}}`: The path where the project is located. diff --git a/src/Dotenv.php b/src/Dotenv.php index 11358f3..676f1b3 100644 --- a/src/Dotenv.php +++ b/src/Dotenv.php @@ -95,9 +95,13 @@ public function getConfig(): array $config = []; if (isset($_SERVER['SOLR_URL'])) { $parts = parse_url($_SERVER['SOLR_URL']); - $config['search_api.server.afa_solr']['backend_config']['connector_config'] = [ - 'host' => $parts['host'], - 'port' => $parts['port'], + $name = $parts['fragment'] ?? 'default'; + $config['search_api.server.' . $name]['backend_config']['connector_config'] = [ + 'scheme' => $parts['scheme'] ?? 'http', + 'host' => $parts['host'] ?? 'localhost', + 'port' => $parts['port'] ?? 8983, + 'path' => $parts['path'] ?? '/', + 'core' => $parts['user'] ?? 'default', ]; } switch ($this->getEnvironmentName()) {