toc

PHP SDK

A full reference of our PHP SDK.

You can use our PHP SDK to:

  1. Encrypt data at your server
  2. Run your Cages

You can use our PHP SDK to encrypt data — rather than with Relay — and still send it to a third-party via Relay. Encrypting with our backend SDKs is best for developers who want to avoid the network latency of Relay and/or want to avoid sending plaintext data to Relay to be encrypted.

Encrypting data with our backend SDKs instead of Relay may expose you to greater compliance burden because plaintext data touches your server before it is encrypted. If you want to avoid sending plaintext data to Relay and want to reduce your compliance burden — by never having plaintext data touch your infrastructure — using our frontend SDKs to encrypt in the browser or on the client is best.

You don’t need to change your database configuration. You can store Evervault-encrypted data in your database as you would the plaintext version.

Installation

Install the Evervault PHP SDK.

  • Composer
  • Install it yourself

Our PHP SDK is distributed via Composer.

bash
composer require evervault/evervault-php

To use the bindings, use Composer's autoload:

php
require_once('vendor/autoload.php');

Initialization

php
use \Evervault\Evervault;
// Insert your API key here
$evervault = new Evervault('<YOUR_API_KEY>');
// Encrypt your sensitive data
$encrypted = $evervault->encrypt([
'name' => 'Alice'
]);
// Process the encrypted data in a Cage
$result = $evervault->run('hello-cage', $encrypted);

Reference

The Evervault PHP SDK exposes two functions:

  • $evervault->encrypt()
  • $evervault->run()

\$evervault->encrypt()

$evervault->encrypt() encrypts data for use in your Cages. To encrypt data on your server, simply pass an array or string into the $evervault->encrypt() function. Store the encrypted data in your database as normal.

php
$evervault->encrypt($data = array | string)
ParameterTypeDescription
$dataarray or stringData to be encrypted.

\$evervault->run()

$evervault->run() lets you invoke a Cage with a given payload.

php
$evervault->run($cageName = string, $data = array[, $options = $array])
ParameterTypeDescription
$cageNamestringName of the Cage to be run.
$dataarrayPayload for the Cage.
$optionsarrayOptions for the cage run.
OptionTypeDefaultDescription
asyncBooleanFalseRun your Cage in async mode. Async Cage runs will be queued for processing.
versionIntegerNullSpecify the version of your Cage to run. By default, the latest version will be run.