A Symfony Bundle containing an Environment Variable Processors for decoding url-encoded strings.
Install and add the bundle:
composer require scitotec/url-decode-env-var-processor-bundle
You can use and combine it with other Environment Variable Processors, e.g.:
# .env
MONGODB_URL="mongodb://db_user:db_pa%24%[email protected]:27017/db_name"
# config/packages/mongodb.yaml
mongo_db_bundle:
clients:
default:
hosts:
- { host: '%env(string:key:host:url:MONGODB_URL)%', port: '%env(int:key:port:url:MONGODB_URL)%' }
username: '%env(string:url_decode:key:user:url:MONGODB_URL)%' # ⬅️
password: '%env(string:url_decode:key:pass:url:MONGODB_URL)%' # ⬅️
connections:
default:
database_name: '%env(key:path:url:MONGODB_URL)%'