PHP code example of nugsoft / hikbridge-laravel-sdk
1. Go to this page and download the library: Download nugsoft/hikbridge-laravel-sdk 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/ */
nugsoft / hikbridge-laravel-sdk example snippets
return [
// Base URL of the HikBridge API (no trailing slash needed)
'base_url' => env('HIKBRIDGE_BASE_URL', 'https://hikbridge.clocknesthr.com/api'),
// Per-business API key (hbk_...) — sent as Authorization: Bearer on every request
'api_key' => env('HIKBRIDGE_API_KEY'),
// HTTP timeout in seconds
'timeout' => (int) env('HIKBRIDGE_TIMEOUT', 30),
// Automatic retry on transient connection-level failures (timeouts,
// DNS/refused connections). HTTP error responses (4xx/5xx) are never
// retried — they are surfaced immediately as typed exceptions (see below).
// Set 'times' to 0 to disable retries entirely
'retry' => [
'times' => 3,
'sleep' => 100, // milliseconds between retries
],
];
// List all devices in the business
$devices = HikBridge::devices()->list();
foreach ($devices['data'] as $device) {
echo $device['id'] . ' — ' . $device['name'];
}
// Get a single device
$device = HikBridge::devices()->get(35);
$result = HikBridge::persons()->deleteFromDevice(personId: 57, deviceId: 35);
// Local record is soft-deleted even if the device is unreachable
$summary = HikBridge::biometrics(57)->summary(deviceId: 35);
// Returns face, fingerprint, and access card status for the person on that device
$base64 = base64_encode(file_get_contents('/path/to/photo.jpg'));
// data-URI prefix (data:image/jpeg;base64,...) is accepted but not aved locally but could not be pushed to the device
// $result['warning']['pushed_to_device'] === false
logger()->warning('Face not pushed to device', $result['warning']);
}
// Trigger capture
HikBridge::biometrics(57)->captureFace(deviceId: 35);
// Poll until done
do {
sleep(2);
$progress = HikBridge::biometrics(57)->faceCaptureProgress(deviceId: 35);
} while ($progress['data']['status'] === 'capturing');
// With a base64 template — downloaded to the device immediately
HikBridge::biometrics(57)->storeFingerprint(
deviceId: 35,
fingerIndex: 1,
template: $base64Template,
);
// With template: null — enrollment recorded locally, no device push
HikBridge::biometrics(57)->storeFingerprint(deviceId: 35, fingerIndex: 1);
// Trigger capture — specify which finger
HikBridge::biometrics(57)->captureFingerprint(deviceId: 35, fingerIndex: 1);
// Poll until done
do {
sleep(2);
$progress = HikBridge::biometrics(57)->fingerprintCaptureProgress(deviceId: 35);
} while ($progress['data']['status'] === 'capturing');
$op->operationId; // string — the operation ID, e.g. "op_abc123"
$op->data; // array — the entity being created or deleted
$op->isPending(); // bool — always true (the operation was just created)
use Nugsoft\HikBridge\Exceptions\ValidationException;
Http::fake([
'*/v1/persons' => Http::response([
'message' => 'The given data was invalid.',
'errors' => ['person_code' => ['The person code field is