Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use env variable as reference of other env variable?

I am using Laravel 5.4 and vlucas/phpdotenv library.

I wants to take reference of one env variable to other env variable e.g.

APP_NAME: JUSTDOIT
SIGNUP_KEY: JUSTDOIT_SIGNUP

here in SIGNUP_KEY I wants to use whatever APP_NAME it is.

like image 656
Chintan7027 Avatar asked Oct 29 '25 07:10

Chintan7027


1 Answers

Ahh, I found the answer here, Not removing the question as it may help to other,

It's possible to nest an environment variable within another, useful to cut down on repetition.

This is done by wrapping an existing environment variable in ${…} e.g.

APP_NAME: JUSTDOIT
SIGNUP_KEY: ${APP_NAME}_SIGNUP

additionally if you wants to use space in variable value then encluse this with "quotes" e.g.

SIGNUP_KEY: "${APP_NAME} SIGNUP"

Reference: https://github.com/vlucas/phpdotenv#nesting-variables

like image 136
Chintan7027 Avatar answered Oct 31 '25 11:10

Chintan7027



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!