PHP code example of jc-it / yii2-secrets

1. Go to this page and download the library: Download jc-it/yii2-secrets 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/ */

    

jc-it / yii2-secrets example snippets


$secrets = new \JCIT\secrets\SecretsService(
    new \JCIT\secrets\storages\Chained(
        new \JCIT\secrets\storages\Cache(getenv()),
        new \JCIT\secrets\storages\Json('/run/env.json'),
        new \JCIT\secrets\storages\Filesystem(__DIR__ . '/secrets'),
    )
);

    class SecretsController extends Controller
    {
        public function actions(): array
        {
            return [
                'extract' => [
                    'class' => Extract::class,
                    'calls' => ['$secrets->get', '$secrets->getAndThrowOnNull'],
                    'sourcePath' => '@app/',
                ],
            ];
        }
    }
  

  ...
  'container' => [
      'definitions' => [
          \JCIT\secrets\interfaces\StorageInterface::class => function() {
              return new \JCIT\secrets\storages\Filesystem(__DIR__ . '/../../../secrets')
          }
      ]
  ],