Local development ENVKEYs

When not to use local development ENVKEYs

Most users won't need to manage local development ENVKEYs manually. As long as an app has a .envkey file and you have the EnvKey App and CLI installed, your development environment with will be loaded automatically. If that's the case, you can follow the Integration Quickstart to connect to an EnvKey environment.

When to use local development ENVKEYs

In some situations, like when you're using containers in development or developing on a VM (whether local or remote), it might not be practical to install the EnvKey App and CLI on the OS running your program. In that case, you can generate a local development ENVKEY instead and use that to connect to your development environment.

It might also be easier to use a local development ENVKEY if you're using a web server like Apache or FastCGI that runs processes under its own OS user like _www or www-data. That's because loading EnvKey development config automatically without a local development ENVKEY requires access to the $HOME/.envkey directory of the OS user that installed EnvKey, which the web server's user typically doesn't have.

Generating the ENVKEY

Open up the EnvKey App, sign in, select the application you want to integrate with in the sidebar, and then select the ENVKEYs tab. Assuming you have permission to manage servers, you'll see a Local Keys section at the top. Click the Generate Local Key button, then copy the generated ENVKEY.

Or you can use the EnvKey CLI:

envkey local-keys create

Now either:

  • Copy your ENVKEY into a file at: $HOME/.envkey/apps/$APP_ID.env. $APP_ID should be replaced with your app's id: look for it in the UI or CLI output after generating a local key.
    Note: this option typically won't work with web servers like Apache or FastCGI that run under a different OS user

  • Copy your ENVKEY into a .env file in the home directory: $HOME/.env.
    Note: this option also typically won't work with web servers like Apache or FastCGI that run under a different OS user

  • Set your ENVKEY as an environment variable that will be visible to your app.

  • Copy your ENVKEY into a version-control-ignored .env file at the root of your project.

From there, follow the integration quickstart from the 'Integrate with your app' section.