setono/variable-resolver

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: 2024-12-15 05:08:45 UTC


README

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.

Installation

$ 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