PHP code example of sunaoka / aws-ssm-parameters-loader-php

1. Go to this page and download the library: Download sunaoka/aws-ssm-parameters-loader-php 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/ */

    

sunaoka / aws-ssm-parameters-loader-php example snippets


use Aws\Ssm\SsmClient;
use Sunaoka\SsmParametersLoader\ParametersLoader;

putenv('MY_PARAMETER=ssm:/path/to/value')

$client = new SsmClient([
    // arguments
]);

$loader = new ParametersLoader($client, 'ssm:');
$loader->load();

echo env('MY_PARAMETER');
// my secret value

use Aws\Ssm\SsmClient;
use Sunaoka\SsmParametersLoader\ParametersLoader;

putenv('MY_PARAMETER=ssm:/path/to/value')

$client = new SsmClient([
    // arguments
]);

$loader = new ParametersLoader($client, 'ssm:');
$result = $loader->getParameters();

var_dump($result);
// array(1) {
//   'MY_PARAMETER' =>
//   string(15) "my secret value"
// }