Commit 34edf43
committed
This PR was squashed before being merged into the 7.1 branch.
Discussion
----------
[DependencyInjection] Add `urlencode` function to `EnvVarProcessor`
| Q | A
| ------------- | ---
| Branch? | 6.4
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| License | MIT
This PR adds `urlencode` to the default `EnvVarProcessor` to allow encoding environment variables in config files.
The comes handy when environment variables are provided by the OS and not through .env because those values are often not compatible with DSN syntax for doctrine or mailer components.
In my case our app was deployed on an AWS stack and environment variables for SMPT and database where automatically provided in the deployment process and replaced in the respective .env files.
Because those values where not encoded they would cause issues with DSN format requireing me to commit them in my `.env.prod` which circumvents the purpose of the whole system.
Usage:
```yaml
# config/packages/mailer.yaml
framework:
mailer:
dsn: 'smtp://%env(urlencode:SMTP_USER)%:%env(urlencode:SMTP_PASSWORD)%@%env(urlencode:SMTP_HOST)%?encryption=%env(SMTP_ENCRYPTION)%&port=%env(SMTP_PORT)%&auth_mode=login'
```
Commits
-------
1439858 [DependencyInjection] Add `urlencode` function to `EnvVarProcessor`
File tree
4 files changed
+18
-0
lines changed- src/Symfony/Component/DependencyInjection
- Tests
- Compiler
4 files changed
+18
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| |||
344 | 345 | | |
345 | 346 | | |
346 | 347 | | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
347 | 352 | | |
348 | 353 | | |
349 | 354 | | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
959 | 959 | | |
960 | 960 | | |
961 | 961 | | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
962 | 973 | | |
963 | 974 | | |
964 | 975 | | |
| |||
0 commit comments