PHP code example of nohnaimer / yii2-vault-client

1. Go to this page and download the library: Download nohnaimer/yii2-vault-client 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/ */

    

nohnaimer / yii2-vault-client example snippets


class m221103_161325_vault_init extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $client = new Client([
            'url' => 'url',
            'token' => 'token',
        ]);

        $kv = new KVv1([
            'path' => '/kv',
            'client' => $client,
        ]);
        
        //add
        $kv->post('/my/secret', ['key' => 'value']);
        
        //delete
        $kv->delete('/my/secret/key');
    }
}
yaml
...
php:
  image: php:latest
  container_name: php
  restart: on-failure
  working_dir: /var/www
  environment:
    VAULT_ADDR: https://127:0:0:1:8200/
    VAULT_TOKEN: hvs.hrpvk3rEpD2HaHckeb976Ppw
  volumes:
    - .:/var/www:cached
  depends_on:
    - postgres
...