PHP code example of dflydev / placeholder-resolver

1. Go to this page and download the library: Download dflydev/placeholder-resolver library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dflydev / placeholder-resolver example snippets


$dsnPattern = '${conn.driver}:dbname=${conn.db_name};host=${conn.hostname}';
$dsn = $placeholderResolver->resolveValue($dsnPattern);
// mysql:dbname=example;host=127.0.0.1

use Dflydev\PlaceholderResolver\RegexPlaceholderResolver;

// YourDataSource implements Dflydev\PlaceholderResolver\DataSource\DataSourceInterface
$dataSource = new YourDataSource;

// Create the placeholder resolver
$placeholderResolver = new RegexPlaceholderResolver($dataSource);

// Start resolving placeholders
$value = $placeholderResolver->resolvePlaceholder('${foo}');

$placeholderResolver = new RegexPlaceholderResolver($dataSource, '<', '>');

array(
    'foo' => 'FOO',
    'bar' => 'BAR',
    'FOO.BAR' => 'BAZ!',
);

// YourCache implements Dflydev\PlaceholderResolver\Cache\CacheInterface
$cache = new YourCache;

$placeholderResolver->setCache($cache);