This is a library that replaces variables like %PHP%
or %APP_ENV%
with their real values. This is typically used
for deployment purposes.
$ composer require setono/variable-resolver
use Setono\VariableResolver\VariableResolver;
use Setono\VariableResolver\Parser\PercentageWrappingParser;
use Setono\VariableResolver\Variable\Value\PhpBinValue;
$str = '%PHP% bin/console run:command';
$variableResolver = new VariableResolver(new PercentageWrappingParser());
$variableResolver->addValue('PHP', new PhpBinValue());
echo $variableResolver->resolve($str); // output: /usr/bin/php bin/console run:command