PHP code example of glen / docker-secrets-provider
1. Go to this page and download the library: Download glen/docker-secrets-provider 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/ */
$this->register(new DockerSecretsProvider(array(
'mongodb' => function ($secretReader, $app) {
// make copy for later assignment,
$options = $app['mongodb.options'];
// make as function to avoid loading secret to memory before it's use is needed
$app['mongodb.options'] = function () use ($secretReader, $options, $app) {
$options['options']['password'] = $secretReader();
return $options;
};
},
)));