HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/magento.bikenow.co/vendor/csharpru/vault-php/docs/index.rst
.. Vault PHP Client documentation master file, created by
   sphinx-quickstart on Thu Aug 10 14:35:27 2017.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

Welcome to Vault PHP Client's documentation!
============================================

.. toctree::
   :maxdepth: 2
   :caption: Contents:

This is a PHP client for Vault - a tool for managing secrets.

Quick start
-----------

.. code-block:: php

    <?php

    use Vault\AuthenticationStrategies\AppRoleAuthenticationStrategy;
    use Vault\AuthenticationStrategies\UserPassAuthenticationStrategy;
    use Vault\AuthenticationStrategies\TokenAuthenticationStrategy;
    use Vault\Client;
    use Zend\Diactoros\RequestFactory;
    use Zend\Diactoros\StreamFactory;
    use Zend\Diactoros\Uri;

    // Creating the client
    $client = new Client(
        new Uri('http://127.0.0.1:8200'),
        new \AlexTartan\GuzzlePsr18Adapter\Client(),
        new RequestFactory(),
        new StreamFactory()
    ); // Using alextartan/guzzle-psr18-adapter and zendframework/zend-diactoros

    // Authenticating using userpass auth backend.

    $authenticated = $client
        ->setAuthenticationStrategy(new UserPassAuthenticationStrategy('test', 'test'))
        ->authenticate();

    // Authenticating using approle auth backend.

    $authenticated = $client
        ->setAuthenticationStrategy(new AppRoleAuthenticationStrategy(
            'd4131206-384f-75fa-11d6-55d1d63c07c0',
            'cac86a12-c566-3932-09f3-5823ccdfa606'
        ))
        ->authenticate();

    // Authenticating using token auth backend.
    $authenticated = $client
        ->setAuthenticationStrategy(new TokenAuthenticationStrategy('463763ae-0c3b-ff77-e137-af668941465c'))
        ->authenticate();

Fetching a secret
-----------------

.. code-block:: php

    <?php

    use Vault\AuthenticationStrategies\TokenAuthenticationStrategy;
    use Vault\Client;
    use Zend\Diactoros\RequestFactory;
    use Zend\Diactoros\StreamFactory;
    use Zend\Diactoros\Uri;

    // Creating the client
    $client = new Client(
        new Uri('http://127.0.0.1:8200'),
        new \AlexTartan\GuzzlePsr18Adapter\Client(),
        new RequestFactory(),
        new StreamFactory()
    ); // Using alextartan/guzzle-psr18-adapter and zendframework/zend-diactoros

    // Authenticating using token auth backend.
    // Request exception could appear here.
    $authenticated = $client
        ->setAuthenticationStrategy(new TokenAuthenticationStrategy('463763ae-0c3b-ff77-e137-af668941465c'))
        ->authenticate();

    if (!$authenticated) {
        // Throw an exception or handle authentication failure.
    }

    // Request exception could appear here.
    /** @var \Vault\ResponseModels\Response $response */
    $response = $client->read('/secret/database');

    $data = $response->getData(); // Raw array with secret's content.

    // ...

Indices and tables
==================

* :ref:`search`