When defining environment variables in the .env file, is there a way of referencing a variable that was defined earlier? I'd like to do something like this:
My only goal is to reduce repetition in the .env file. The index name is environment specific, and it is repeated many times in the environment variables.
Of course I can write it out manually on each row, or use a placeholder and insert it in code. But if there's a way of injecting INDEX_NAME to other variables, that would be more elegant.
Laravel's documentation tells that they use the DotEnv PHP library for environment configuration. From its source code I found out that it supports nested variables, which is exactly what I needed. See the function Dotenv\Loader->resolveNestedVariables for reference.
Here's an example for anyone looking for a solution: