@@ -21,6 +21,95 @@ Install the package using Composer:
2121composer require securitybunker/databunkerpro-php
2222```
2323
24+ ## Quickstart
25+
26+ You need a Databunker Pro instance to talk to. Demo mode gives you one in a single command — no database, no configuration, everything held in memory:
27+
28+ ``` bash
29+ docker run -p 3000:3000 -d --rm --name databunkerpro securitybunker/databunkerpro demo
30+ ```
31+
32+ Check that it came up:
33+
34+ ``` bash
35+ docker logs databunkerpro
36+ ```
37+
38+ ```
39+ Databunker Pro demo is ready
40+ Web UI: http://localhost:3000/
41+ Root access token: DEMO
42+ Database: in-memory, erased on restart
43+ ```
44+
45+ The root access token in demo mode is the fixed string ` DEMO ` . Save this as ` quickstart.php ` :
46+
47+ ``` php
48+ <?php
49+ require __DIR__ . '/vendor/autoload.php';
50+
51+ use DatabunkerPro\DatabunkerproApi;
52+
53+ $api = new DatabunkerproApi('http://localhost:3000', 'DEMO');
54+
55+ // Create a user record. The vault encrypts the profile and returns a user token.
56+ $created = $api->createUser([
57+ 'email' => 'john@phptest.com',
58+ 'name' => 'John Doe',
59+ 'phone' => '+15551234567',
60+ ]);
61+ echo "User token: " . $created['token'] . "\n";
62+
63+ // Read the record back by any indexed field: token, login, email, phone, custom.
64+ $user = $api->getUser('email', 'john@phptest.com');
65+ echo "Profile: " . json_encode($user['profile']) . "\n";
66+
67+ // Store an encrypted file against that user, tagged by document type.
68+ $file = $api->createFile(
69+ 'email',
70+ 'john@phptest.com',
71+ 'passport.jpg',
72+ base64_encode('fake passport scan bytes'),
73+ ['tags' => ['passport', 'kyc']]
74+ );
75+ echo "File uuid: " . $file['fileuuid'] . " | tags: " . implode(',', $file['tags']) . "\n";
76+
77+ // List the user's files, filtered by tag.
78+ $listing = $api->listUserFiles('email', 'john@phptest.com', 'kyc');
79+ echo "Files tagged kyc: " . implode(',', array_column($listing['files'], 'filename')) . "\n";
80+
81+ // Fetch the file back. Content returns base64-encoded in filedata.
82+ $fetched = $api->getFile('email', 'john@phptest.com', ['fileuuid' => $file['fileuuid']]);
83+ echo "Decrypted: " . base64_decode($fetched['filedata']) . "\n";
84+
85+ // Delete user record.
86+ $api->deleteUser('email', 'john@phptest.com');
87+ echo "User deleted\n";
88+ ```
89+
90+ ``` bash
91+ php quickstart.php
92+ ```
93+
94+ ```
95+ User token: a58765a6-22bc-a806-a1b8-b71205f235fd
96+ Profile: {"email":"john@phptest.com","name":"John Doe","phone":"+15551234567"}
97+ File uuid: 1ca799e7-1554-e559-96d9-4f8a64be9624 | tags: kyc,passport
98+ Files tagged kyc: passport.jpg
99+ Decrypted: fake passport scan bytes
100+ User deleted
101+ ```
102+
103+ Tags are lowercased, de-duplicated and sorted on write, which is why they come back in a different order than they were sent.
104+
105+ When you are done, stop the instance. It was started with ` --rm ` , so the container and its in-memory database are discarded:
106+
107+ ``` bash
108+ docker stop databunkerpro
109+ ```
110+
111+ > ** Demo mode is for evaluation only.** The database is in memory, the wrapping key is a fixed public value, and the root token is the well-known string ` DEMO ` . Never point it at real personal data. For a real deployment see the [ installation guide] ( https://docs.databunker.org/pro/installation/docker-compose ) .
112+
24113## Usage
25114
26115``` php
@@ -39,15 +128,15 @@ $api = new DatabunkerproApi(
39128
40129// Create a user
41130$result = $api->createUser([
42- 'email' => 'user@example .com',
131+ 'email' => 'john@phptest .com',
43132 'name' => 'John Doe'
44133]);
45134
46135// Get user information
47- $user = $api->getUser('email', 'user@example .com');
136+ $user = $api->getUser('email', 'john@phptest .com');
48137
49138// Update user
50- $api->updateUser('email', 'user@example .com', [
139+ $api->updateUser('email', 'john@phptest .com', [
51140 'name' => 'John Smith'
52141]);
53142```
0 commit comments