Config override for local dev

Tagged:
  • todd-crowder
    Participant
    1 month, 2 weeks ago #45856

    Hi, our server uses a Host setting of ‘localhost’ for elasticsearch. But for local development we use DDEV/Docker and host is ‘elasticsearch’. When we download a database from server to work, we have to manually change host each time for the indexes.

    Is there a config setting to allow us to set the host for elasticsearch?

    If not that would be a great help for development. Better if all settings could be overridden.
    thanks

    wpsolr
    Keymaster
    1 month, 2 weeks ago #45857

    All WPSolr settings can be exported and reimported. You can update the Elasticsearch host in the json content before the import.

    todd-crowder
    Participant
    1 month, 2 weeks ago #45858

    Yes, but that’s a manual process. I might as well manually change it in the UI. It’s just the one setting.

    This also makes it hard to do automated testing if we can’t automatically set the host setting in a config file to override production settings. For example, Redis plugins allow you to set config settings that override the default set in the plugin for development and automated testing.

    Please consider making at least host a config setting so we can override. I bet people would also like port #.
    thanks

    wpsolr
    Keymaster
    1 month, 2 weeks ago #45859

    I do not understand how changing the Elasticsearch host can be part of the plugin settings. It looks more about docker compose settings or /etc/hosts

    todd-crowder
    Participant
    1 month, 2 weeks ago #45860

    When you setup an elasticsearch index in wpsolr, you give the hostname of the elasticsearch instance to talk to. That’s the setting that would be good to allow us to override with a config setting.

    Then when I run my automated testing, I spin up a docker instance with elasticsearch, which in DDEV is ‘elasticsearch’, but could be anything. So I need to change that when I grab the production database. All our other enterprise plugins allow us to use config settings to override the hostname, port of services. So this would be really helpful.

    wpsolr
    Keymaster
    1 month, 2 weeks ago #45861

    Could you show me here examples of how the other enterprise plugins do that?

    todd-crowder
    Participant
    1 month, 2 weeks ago #45862

    Yes, here’s how Redis cache does it:
    https://github.com/rhubarbgroup/redis-cache/#configuration
    WP_REDIS_HOST 127.0.0.1 The hostname of the Redis server
    WP_REDIS_PORT 6379 The port of the Redis server
    etc.
    It’s really good because I can set those in my local dev and keep the production settings in the plugin configuration itself. My local settings override the plugins. Works great for automated testing too.
    thanks

    wpsolr
    Keymaster
    1 month, 2 weeks ago #45863

    My local settings override the plugins

    How? Is it stored in an external file?

    todd-crowder
    Participant
    1 month, 2 weeks ago #45864

    in wp-config.php. I can set production to it’s values and on dev to different values (same as changing db settings that way).

    or in my case I’m using dot-env with Bedrock https://roots.io/bedrock/, and I have a .env that has all my local settings.

    wpsolr
    Keymaster
    1 month, 2 weeks ago #45866

    I understand now. Basically, a defined PHP constant can be set to override the database settings, loaded by some WP code or by external frameworks like BedRock .env

    The problem being that WPSolr supports multi-indexes, multi-views configuration. Some engines use a domain, some an endpoint, some http/https, some ports, and so on.

    Which implies that the constant must be able to map the same multi-level structure as the full settings.

    I have think about that before acting.

    todd-crowder
    Participant
    1 month, 2 weeks ago #45867

    yes, or a json file that let’s us override whatever is needed, but connection information is probably enough for everyone.

    if we’re on a dev domain, look for an override file and load over saved settings.

    Or, we could export all settings, change what’s needed, and the whole config file is loaded each time instead of plugin settings, or auto-loads if changed? it’s dev, so that would be ok.

    thanks for considering

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.