PHP code example of tanemrahman / zkteco-adms

1. Go to this page and download the library: Download tanemrahman/zkteco-adms 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/ */

    

tanemrahman / zkteco-adms example snippets


use TanemRahman\ZktecoAdms\Facades\ZktecoAdms;

// Queue user to device — local roster updates only after successful devicecmd reply
ZktecoAdms::addUser('DEVICE-SN', [
    'pin' => 1001,
    'name' => 'Karim',
    'privilege' => 0,      // 0=user, 14=admin
    'password' => '',
    'card' => '',
    'verify_mode' => 15,   // optional USERINFO Verify= (firmware-dependent)
]);

ZktecoAdms::deleteUser('DEVICE-SN', 1001);

// Soft punch-block: remove from device, keep local roster row (is_blocked=true)
ZktecoAdms::blockUser('DEVICE-SN', 1001);
ZktecoAdms::unblockUser('DEVICE-SN', 1001); // clears flag + re-queues USERINFO

// Fingerprint / face template push (raw TMP from another device or export)
ZktecoAdms::addFingerprint('DEVICE-SN', [
    'pin' => 1001,
    'fid' => 0,
    'tmp' => $base64OrHexTemplate,
]);

ZktecoAdms::addFace('DEVICE-SN', [
    'pin' => 1001,
    'fid' => 0,
    'tmp' => $faceTemplate,
]);

ZktecoAdms::deleteFingerprint('DEVICE-SN', 1001, 0);
ZktecoAdms::deleteFace('DEVICE-SN', 1001, 0);

// Device control
ZktecoAdms::reboot('DEVICE-SN');
ZktecoAdms::syncTime('DEVICE-SN');
ZktecoAdms::info('DEVICE-SN');
ZktecoAdms::check('DEVICE-SN');          // re-handshake
ZktecoAdms::clearLog('DEVICE-SN');       // clear attendance on device
ZktecoAdms::clearData('DEVICE-SN');      // clear operation data
ZktecoAdms::queryUsers('DEVICE-SN');     // ask device to re-upload USERINFO
ZktecoAdms::queryAttlog('DEVICE-SN', '2026-08-01 00:00:00', '2026-08-10 23:59:59');
ZktecoAdms::resetStamps('DEVICE-SN');    // force re-upload on next handshake

use TanemRahman\ZktecoAdms\Models\ZktecoDevice;

public function index()
{
    $devices = ZktecoDevice::query()
        ->orderByDesc('last_seen_at')
        ->paginate(20);

    return view('zkteco.devices.index', compact('devices'));
}

use TanemRahman\ZktecoAdms\Facades\ZktecoAdms;

public function storeUser(Request $request, string $serial)
{
    $data = $request->validate([
        'pin' => 'ccess', 'User queued to device.');
}

use TanemRahman\ZktecoAdms\Models\ZktecoTransaction;

$punches = ZktecoTransaction::query()
    ->where('source', 'adms')
    ->whereDate('timestamp', today())
    ->orderByDesc('timestamp')
    ->paginate(50);

use App\Models\Employee;
use TanemRahman\ZktecoAdms\Models\ZktecoTransaction;

$txn = ZktecoTransaction::latest('timestamp')->first();

$employee = Employee::where('biometric_emp_id', $txn->user_id)->first();
// create/update your attendances row…

use TanemRahman\ZktecoAdms\Events\TransactionsReceived;
use TanemRahman\ZktecoAdms\Events\AttendancePhotoReceived;
use TanemRahman\ZktecoAdms\Events\DeviceRegistered;
use TanemRahman\ZktecoAdms\Events\CommandCompleted;
use TanemRahman\ZktecoAdms\Events\UsersSynced;

Event::listen(TransactionsReceived::class, function (TransactionsReceived $e) {
    // $e->device, $e->saved, $e->pins, $e->summary, $e->records (

ZktecoTransaction::where('source', 'adms')->…;
ZktecoTransaction::where('source', 'biotime')->…;
bash
composer update tanemrahman/zkteco-adms
php artisan migrate
php artisan vendor:publish --tag=zkteco-adms-config
bash
composer update tanemrahman/zkteco-adms
php artisan migrate
bash
php artisan vendor:publish --tag=zkteco-adms-config