The Symfony documentation provides an example of setting a configuration parameter from the output of a PHP script:
parameters:
env(PHP_FILE): '../config/.runtime-evaluated.php'
app:
auth: '%env(require:PHP_FILE)%'
Where the content of .runtime-evaluated.php is e.g.:
<?php
$today = new \DateTime();
$spring = new \DateTime('March 1');
$summer = new \DateTime('June 1');
$fall = new \DateTime('September 1');
$winter = new \DateTime('December 1');
if ($today >= $spring && $today < $summer) {
return 'spring';
} else if ($today >= $summer && $today < $fall) {
return 'summer';
} else if ($today >= $fall && $today < $winter) {
return 'fall';
} else {
return 'winter';
}
?>
On Windows using Devsense PHP Tools 1.40.1.2223 the current directory is incorrect, resulting in the error message:
!! In EnvVarProcessor.php line 118:
!!
!! File "../config/.runtime-evaluated.php" not found (resolved from "PHP_FILE").
On Linux in both command-line and Apache this works fine.