1. Go to this page and download the library: Download nazamey/zktecodevices 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/ */
nazamey / zktecodevices example snippets
Nazamey\Zktecodevices\ZKTecoDeviceManager;
// Initialize connection
$zk = new ZKTecoDeviceManager('192.168.1.100', 4370, 0, 'auto');
try {
// Test connection
$zk->testConnection();
// Get device information (if your abstraction exposes it)
$deviceInfo = $zk->getDeviceInfo();
// Extract users
$users = $zk->getUsers();
// Extract attendance records
$attendance = $zk->getAttendanceLogs();
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
use Nazamey\Zktecodevices\ZKTecoDeviceManager;
$device_ip = "192.168.1.100";
$password = 0; // Device password (0 = no password)
$zk = new ZKTecoDeviceManager($device_ip, 4370, $password, 'auto');
// Example: extract all data in your preferred format
$users = $zk->getUsers();
$attendance = $zk->getAttendanceLogs();
// Persist them as needed (CSV/JSON/DB/etc.)
[
'uid' => 1, // User ID
'user_id' => '1001', // Badge number
'name' => 'John Doe', // User name
'privilege' => 14, // User privilege level
'password' => '', // User password
'group_id' => 1, // Group ID
'card' => 0 // Card number
]
[
'uid' => 1, // User ID
'user_id' => '1001', // Badge number
'timestamp' => '2025-10-22 09:15:30', // Date and time
'status' => 1, // Check-in/out status
'punch' => 1, // Punch type
'date' => '2025-10-22', // Date only
'time' => '09:15:30' // Time only
]