Download the PHP package novadaemon/skyflow-php without Composer
On this page you can find all versions of the php package novadaemon/skyflow-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download novadaemon/skyflow-php
More information about novadaemon/skyflow-php
Files in novadaemon/skyflow-php
Package skyflow-php
Short Description This PHP SDK is designed to help developers easily implement Skyflow into their php backend.
License MIT
Informations about the package skyflow-php
Skyflow-PHP
Description
This PHP SDK is designed to help developers easily implement Skyflow into their php backend.
Table of Contents
- Features
- Installation
- Requirements
- Install
- Examples
- Prerequisites
- Create the vault
- Create a Service Account
- Service Account Bearer Token Generation
- Vault API
- Get records
- Get record by ID
- Insert records
- Update record
- Delete record
- Bulk delete records
- Detokenization
- Tokenization
- Execute SQL Query
- Invoke Connection
Features
Authentication with a Skyflow Service Account and generation of a bearer token.
Vault API operations to insert, retrieve, update, delete and tokenize sensitive data.
Execute SQL queries into vault scheme.
Invoking connections to call downstream third party APIs without directly handling sensitive data.
Installation
Requirements
- Require PHP 8.1 or above
-
You need to have installed Composer
Install
Type in your terminal:
Examples
You can find samples for all the features of the SDK in the samples
directory. To run a given example:
- Download the repository using
git clone https://github.com/novadaemon/skyflow-php.git
- Run
$ composer install
into directory project. - Go to the
samples
directory in your terminal. - Change the values enclosed by
<>
for the right values into the example file. - Execute the example you want:
$ php get_records.php
Prerequisites
- A Skyflow account. If you don't have one, register for one on the Try Skyflow page.
- PHP 8.1 or above.
- GIT
Create the vault
- In a browser, sign in to Skyflow Studio.
- Create a vault by clicking Create Vault > Start With a Template > Quickstart vault.
- Once the vault is ready, click the gear icon and select Edit Vault Details.
- Note your Vault URL and Vault ID values, then click Cancel. You will need these later.
Create a Service Account
- In the side navigation click, IAM > Service Accounts > New Service Account.
- For Name, enter "SDK Sample". For Roles, choose Vault Editor.
- Click Create. Your browser downloads a credentials.json file. Keep this file secure, as You will need it for each of the samples.
Service Account Bearer Token Generation
The Novadaemon\SkyFlow\ServiceAccount\Token class is used to generate service account tokens from service account credentials file which is downloaded upon creation of service account. The token generated from this class is valid for 60 minutes and can be used to make API calls to vault services as well as management API(s) based on the permissions of the service account.
The Token::generateBearerToken($credentialsPath)
static method takes the credentials file path for token generation, alternatively, you can also send the entire credentials as array, by using Token::generateBearerTokenFromCredentials($credentials)
Example using filepath:
Example using credentials:
Response:
Vault API
The Novadaemon\Skyflow\Vault\Client has all methods to perform operations on the vault such as get records, inserting records, detokenizing tokens, retrieving tokens for a skyflow_id, excute sql query and to invoke a connection.
To use this class, the skyflow client must first be initialized as follows.
All Vault API endpoints must be invoked using a client instance.
Get Records
Use the method Client@getRecords()
to perform bulk operation of retrieve records of table. This method has the following parameters:
Parameter | Description | Type | Required? | Default |
---|---|---|---|---|
table | Name of the table that contains the records | string | yes | none |
ids | Values of the records to return. If not specified, this operation returns all records in the table. | array | no | null |
redaction | Redaction level to enforce for the returned records. Subject to policies assigned to the API caller. | RedactionType | no | RedactionType::DEFAULT |
tokenization | If true, this operations returns tokens instead of field values where applicable. Only applicable if skyflow_id values are specified. | bool | no | null |
fields | Fields to return for the records. If not specified, all fields are returned. | array | no | null |
columnName | Name of the column. It must be configured as unique in the schema. | string | no | null |
columnValues | Column values of the records to return. column_name is mandatory when providing column_values | array | no | null |
offset | Record position at which to start receiving data. | int | no | 0 |
limit | Number of record to return. Maximum 25. | int | no | 25 |
Note:
There are parameters that cannot be used together with others. If you pass the getRecords method arguments incorrectly, a SkyflowException is thrown.
Note:
If the tokenization argument is true, you can set only tokenized field names in the fields parameter. An error is returned if you set the tokenization parameter to true and set a non-tokenized field name in the fields parameter.
An example of Client@getRecords()
call:
Response:
Error:
Get record by id
To retrieve only once record from your Skyflow vault, use the method Client@getRecordById()
. This method has the following parameters:
Parameter | Description | Type | Required? | Default |
---|---|---|---|---|
table | Name of the table that contains the records | string | yes | none |
id | Skyflow id of the record | string | yes | none |
redaction | Redaction level to enforce for the returned records. Subject to policies assigned to the API caller. | RedactionType | no | RedactionType::DEFAULT |
tokenization | If true, this operations returns tokens instead of field values where applicable. Only applicable if skyflow_id values are specified. | bool | no | null |
fields | Fields to return for the records. If not specified, all fields are returned. | array | no | null |
An example of Client@getRecordById()
call:
Response:
Error:
Insert records into the vault
To insert data into your vault use the Cient@insertRecord()
method. The parameters to this method are:
Parameter | Description | Type | Required? | Default |
---|---|---|---|---|
table | Name of the table that contains the records | string | yes | none |
records | Records to insert | array | yes | none |
tokenization | If true, this operations returns tokens instead of field values where applicable. Only applicable if skyflow_id values are specified. | bool | no | null |
upsert | Name of a unique column in the table. Uses upsert operations to check if a record exists based on the unique column's value. If it does, the record updates with the values you provide. If it does not, the upsert operation inserts a new record. | string | no | null |
An example of Client@insertRecords()
call:
Response:
Error:
Update record
To update data in your vault, use the Client@updateRecord()
method. The parameters to this method are:
Parameter | Description | Type | Required? | Default |
---|---|---|---|---|
table | Name of the table that contains the records | string | yes | none |
id | Skyflow id of the record | string | yes | none |
record | Fields with new values to update | array | no | null |
tokenization | If true, this operations returns tokens instead of field values where applicable. Only applicable if skyflow_id values are specified. | bool | no | null |
An example of Client@updateRecord()
call:
Response:
Error:
Delete record
The Client@deleteRecord()
allow you to delete a record from your Skyflow vault. This method has the following parameters:
Parameter | Description | Type | Required? | Default |
---|---|---|---|---|
table | Name of the table that contains the records | string | yes | none |
id | Skyflow id of the record | string | yes | none |
An example of Client@deleteRecord()
call:
Response:
Error:
Bulk delete
The Client@bulkDelete()
allow you to delete specified record from your Skyflow vault. This method has the following parameters:
Parameter | Description | Type | Required? | Default |
---|---|---|---|---|
table | Name of the table that contains the records | string | yes | none |
ids | kyflow id values of the records to delete. If * is specified, this operation deletes all records in the table. | array | yes | ['*'] |
An example of Client@bulkDelete()
call:
Response:
Error:
Detokenization
In order to retrieve data from your vault using tokens that you have previously generated for that data, you can use the Client@detokenize()
method. The parameters to this method are:
Parameter | Description | Type | Required? | Default |
---|---|---|---|---|
params | Detokenization details | array | yes | none |
An example of Client@detokenize()
call:
Response:
Error:
Note:
The structure for each item of the params parameter is:
Tokenization
The method Client@tokenize()
method returns tokens that correspond to the specified records. Only applicable for fields with deterministic tokenization. The parameters to this method are:
Parameter | Description | Type | Required? | Default |
---|---|---|---|---|
params | Tokenization details | array | yes | none |
Note:
This endpoint doesn't insert records, it returns tokens for existing values. To insert records and tokenize that new record's values, see Insert Records and the tokenization parameter.
An example of Client@tokenize()
call:
Response:
Error:
Execute SQL Query
The method Client@query()
returns record for a valid SQL query. While this endpoint retrieves columns under a valid redaction scheme, it can't retrieve tokens. Only supports the SELECT command. The parameters to this method are:
Parameter | Description | Type | Required? | Default |
---|---|---|---|---|
query | The SQL query to execute. | string | yes | none |
Note:
See the Skyflow API Documentation to know moer about the query restrictions.
An example of Client@query()
call:
Error:
Invoke Connection
Using Skyflow Connection, end-user applications can integrate checkout/card issuance flow with their apps/systems. To invoke connection, use the Client@invokeConnection()
method of the Skyflow client. This method accepts the following parameters:
Paramater | Description | Type | Required? | Default |
---|---|---|---|---|
connectionUrl | The connection URL. Must be the entire url for the route | string | yes | none |
method | The connection route request method | RequestMethodType | yes | none |
headers | Connection route request headers | array | no | null |
body | Connection route request body | array | no | null |
pathParams | Url path variables | array | no | null |
queryParams | Query parameters | array | no | null |
Note:
See the Skyflow API Documentation to know more about Connections.
An example of Client@invokeConnection()
call: