[php-src] PR #11351: Add fallback value syntax for ini variables
| From: | Misterio77 | Date: | Tue, 30 May 2023 23:55:00 +0000 |
| Subject: | [php-src] PR #11351: Add fallback value syntax for ini variables | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-22630@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/11351
Author: Misterio77
Hi, all!
This PR implements fallback/default values when substituting variables on ini files. I was actually
surprised this wasn't implemented yet, as it's a very useful feature.
I'm know a thing or two about lexers/parsers, but it's not something I'm super
familiar with, so let me know if there's any way this can be improved!
At the moment, the fallback value is treated similarly to a raw string, so it does not support
arbitrary expressions (such as nested variables), I couldn't get it to without adding state
pushes and pops everywhere on the lexer.
As I understand, this should go through the RFC process? If so, I'm totally okay with writing
one :). Let me know if there's any etiquette I might have missed, too.
---
As an example, my usecase is using environment variables to configure php-fpm, while also having
some sane defaults. Like so:
```ini
error_log = syslog
daemonize = false
[www]
listen = localhost:${DRUPAL_FPM_PORT:-9000}
```