Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSN connection string support, configure via Config (instead of env vars) #368

Open
dkarlovi opened this issue Jul 14, 2022 · 0 comments
Open

Comments

@dkarlovi
Copy link

  • Symfony version: 5.4
  • Algolia Search Bundle version: 6.0
  • Algolia Client Version: 3.3.0
  • Language Version: 8.0

Description

Currently, the client definition looks like this

        <service id="search.client" class="Algolia\AlgoliaSearch\SearchClient" public="true" lazy="true">
            <factory class="Algolia\AlgoliaSearch\SearchClient" method="create" />
            <argument key="$appId">%env(ALGOLIA_APP_ID)%</argument>
            <argument key="$apiKey">%env(ALGOLIA_API_KEY)%</argument>
        </service>

This is not how Symfony bundles typically do this because it creates a hard requirement the credentials need to be in env vars, which is not what what you want to do.

A better approach is to use the bundle's config, like so

algolia_search:
   id: 123
   key: s3cr3t

This allows the developer to still use env:

algolia_search:
   id: %env(ALGOLIA_APP_ID)%
   key: %env(ALGOLIA_API_KEY)%

but they can choose other ways to do it to, like Symfony secrets.

Extending this idea, a further optimization would be to bundle the ID/key in one param, a sort of a DSN like Doctrine and other Symfony components use. This allows storing the entire thing as a secret and keeping it all together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant