Replace variables in strings with real values

dev-master / 1.0.x-dev 2020-05-25 12:06 UTC

This package is auto-updated.

Last update: 2023-11-26 13:34:52 UTC


Latest Version Latest Unstable Version Software License Build Status Coverage Status Quality Score

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

Basic usage

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