alauddin020 / zkteco
ZKTeco attendance devices for Laravel: SDK client (old, comm-key and secure 6001 firmware over UDP/TCP), ADMS push receiver, device management, day-wise sync, attendance dashboard and ZKBio Time import.
Requires
- php: >=8.0
- ext-openssl: *
- ext-sockets: *
- guzzlehttp/guzzle: >=6.5.5
- illuminate/cache: >=8.0
- illuminate/console: >=8.0
- illuminate/database: >=8.0
- illuminate/http: >=8.0
- illuminate/routing: >=8.0
- illuminate/support: >=8.0
- illuminate/validation: >=8.0
- illuminate/view: >=8.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Composer package alauddin020/zkteco ยท PHP namespace Alal\Zkteco
Everything a Laravel app needs to take attendance from ZKTeco devices:
- SDK client (port 4370) for old firmware, comm-key firmware and the new secure "6001" firmware (RSA + AES), over UDP or TCP.
- Push / ADMS receiver (
/iclock/...) for devices in Cloud Server mode, Push protocol 2.x and 3.x (registry, rtlog, querydata). This is the only way to get logs from firmware that returns 0 records over the SDK. - Device management stored in the database (name, model, location, serial, IP, protocol, port, comm key, status).
- Attendance dashboard: date-wise punch list with punch time, Prev / Next day, and a Daily In / Out view (first / last punch, duration, all times).
- JSON API with the same features for SPAs, mobile apps and other services (Sanctum token auth), and optional permissions (Gate / spatie) per action.
- Day-wise sync:
zkteco:sync --today, scheduled automatically. - Optional forwarding of push traffic to another ADMS server (e.g. ZKBio Time) and optional import from the ZKBio Time web REST API.
Works with Laravel 8 and every later version (no upper version limit) on PHP 8.0+.
Contents
- Requirements
- Installation
- Configuration
- Dashboard
- Devices
- Getting punches: SDK vs push
- Push (ADMS) setup
- Sync command and scheduler
- Forwarding to ZKBio Time
- ZKBio Time API import
- Using the SDK client in code
- Models and database
- Customising
- Troubleshooting
- Upgrading from zkt/laravel-zkteco
- Credits and license
Requirements
| PHP | 8.0 or newer, with ext-sockets and ext-openssl |
| Laravel | 8.0 or newer (8, 9, 10, 11, 12, 13, ...) |
| Database | any Laravel database (MySQL, MariaDB, PostgreSQL, SQLite, SQL Server) |
| Cache | any store; a store with locks (database, redis, file, ...) is recommended for push commands |
On Windows enable extension=sockets and extension=openssl in php.ini.
Installation
composer require alauddin020/zkteco
The service provider and the Zkteco facade are auto-discovered.
Then publish the config and create the tables:
php artisan zkteco:install
zkteco:install publishes config/zkteco.php and runs the migrations. Options:
| Option | Effect |
|---|---|
--views |
also publish the Blade views to resources/views/vendor/zkteco |
--migrations |
publish the migrations to database/migrations (then set run_migrations to false) |
--no-migrate |
do not run the migrations |
Or do it by hand:
php artisan vendor:publish --tag=zkteco-config php artisan migrate
Installing from a local folder
To use the package from a folder inside your project (e.g. packages/alauddin020/zkteco):
"repositories": [ { "type": "path", "url": "packages/alauddin020/zkteco", "options": { "symlink": true } } ], "require": { "alauddin020/zkteco": "@dev" }
composer update alauddin020/zkteco
Publishable resources
| Tag | What | Where |
|---|---|---|
zkteco-config |
configuration | config/zkteco.php |
zkteco-migrations |
migrations | database/migrations |
zkteco-views |
Blade views | resources/views/vendor/zkteco |
zkteco-routes |
route files (reference copy) | routes/zkteco.php, routes/zkteco-api.php, routes/zkteco-iclock.php |
php artisan vendor:publish --tag=zkteco-views
Configuration
All options live in config/zkteco.php. The most important ones:
'tables' => [ 'devices' => 'zkteco_devices', 'attendance_logs' => 'zkteco_attendance_logs', ], 'routes' => [ 'enabled' => true, 'prefix' => 'zkteco', // dashboard at /zkteco 'middleware' => ['web', 'auth'], // protect it! 'name' => 'zkteco.', ], 'iclock' => [ 'enabled' => true, // /iclock/* push endpoints 'forward_url' => null, // e.g. http://192.168.20.40:8081 'log_requests' => true, ], 'schedule' => [ 'enabled' => true, 'today' => '*/5 * * * *', // zkteco:sync --today 'yesterday' => '00:05', // zkteco:sync --date=yesterday ],
Environment variables:
| Variable | Default | Meaning |
|---|---|---|
ZKTECO_DEVICES_TABLE |
zkteco_devices |
devices table name |
ZKTECO_ATTENDANCE_LOGS_TABLE |
zkteco_attendance_logs |
punches table name |
ZKTECO_ROUTES |
true |
register the dashboard routes |
ZKTECO_ROUTE_PREFIX |
zkteco |
dashboard URL prefix ('' = site root) |
ZKTECO_PERMISSION_VIEW / _SYNC / _MANAGE |
- | Gate ability per action, dashboard and API (permissions) |
ZKTECO_API |
true |
register the JSON API |
ZKTECO_API_PREFIX |
api/zkteco |
JSON API URL prefix |
ZKTECO_ICLOCK |
true |
register the /iclock push routes |
ZKTECO_ICLOCK_LOG |
true |
log every push request (except polling) |
ZKTECO_ADMS_FORWARD_URL |
- | also relay push traffic to this ADMS server |
ZKTECO_ADMS_FORWARD_TIMEOUT |
15 |
seconds |
ZKTECO_SCHEDULE |
true |
register the sync schedule |
ZKTECO_SCHEDULE_CRON |
*/5 * * * * |
cron for zkteco:sync --today |
ZKTECO_SCHEDULE_YESTERDAY_AT |
00:05 |
time for zkteco:sync --date=yesterday |
BIOTIME_URL, BIOTIME_USERNAME, BIOTIME_PASSWORD |
- | ZKBio Time API import |
ZKTECO_DEVICE |
- | default device for Zkteco::device() |
Change the table names before running the migrations.
Dashboard
Open /{prefix} (default /zkteco).
| Route name | URL | Page |
|---|---|---|
zkteco.attendance.index |
GET /zkteco |
Attendance, date-wise (default: today) |
zkteco.attendance.sync |
POST /zkteco/sync |
"Sync today" / "Sync all" buttons |
zkteco.devices.index |
GET /zkteco/devices |
Device list |
zkteco.devices.create / store |
/zkteco/devices/create |
Add device |
zkteco.devices.show |
GET /zkteco/devices/{name} |
Live device info + users (SDK) |
zkteco.devices.edit / update |
/zkteco/devices/{name}/edit |
Edit device |
zkteco.devices.destroy |
DELETE /zkteco/devices/{name} |
Delete device (logs are kept) |
zkteco.devices.toggle |
PATCH /zkteco/devices/{name}/toggle |
Active / Inactive |
zkteco.devices.attendance |
GET /zkteco/devices/{name}/attendance.json |
Live SDK read as JSON (?debug=1 for diagnostics) |
Attendance page
- All punches: date, punch time, user ID, punch (Check In/Out ...), verify (Face, Fingerprint ...), device.
- Daily In / Out: one row per user per day with the first punch (In), last punch (Out), duration and every punch time.
- Filters: device, user ID, from / to date. With one day selected, Prev day / Next day buttons appear; ranges are grouped by day.
Prefix, login and permissions
All dashboard routes are registered by the service provider inside one group
built from config/zkteco.php:
'routes' => [ 'prefix' => 'zkteco', // URLs: /zkteco, /zkteco/devices, ... 'middleware' => ['web', 'auth'], // login required 'name' => 'zkteco.', 'permissions' => [ 'view' => null, // attendance list, device list / info, live JSON 'sync' => null, // "Sync today" / "Sync all" buttons 'manage' => null, // add / edit / delete / activate devices ], ],
- Prefix: e.g.
'prefix' => 'admin/attendance'serves the dashboard at/admin/attendance.''serves it at the site root. - Login:
auth(default) sends guests to yourloginroute. Apps without a login page (API only) get401 Unauthenticatedinstead of theRoute [login] not definederror: the package servesauth/auth:guardwith its ownzkteco.authmiddleware. Use another guard with'auth:admin', or add more middleware ('verified', your own role middleware, ...). - Permissions: give an action a Gate ability and the routes get Laravel's
can:middleware. Users without it get 403, and its buttons are hidden.null= no extra check.
| Action | Routes |
|---|---|
view |
GET /, GET /devices, GET /devices/{name}, GET /devices/{name}/attendance.json |
sync |
POST /sync |
manage |
GET /devices/create, POST /devices, GET /devices/{name}/edit, PUT/PATCH /devices/{name}, DELETE /devices/{name}, PATCH /devices/{name}/toggle |
Also settable from .env: ZKTECO_PERMISSION_VIEW, ZKTECO_PERMISSION_SYNC, ZKTECO_PERMISSION_MANAGE.
With Laravel Gates (e.g. in AppServiceProvider::boot()):
use Illuminate\Support\Facades\Gate; Gate::define('zkteco.view', fn ($user) => $user->is_admin || $user->is_hr); Gate::define('zkteco.sync', fn ($user) => $user->is_admin || $user->is_hr); Gate::define('zkteco.manage', fn ($user) => $user->is_admin);
'permissions' => [ 'view' => 'zkteco.view', 'sync' => 'zkteco.sync', 'manage' => 'zkteco.manage', ],
With spatie/laravel-permission (permissions are checked through the Gate, so the same config works):
use Spatie\Permission\Models\Permission; use Spatie\Permission\Models\Role; Permission::findOrCreate('zkteco.view'); Permission::findOrCreate('zkteco.sync'); Permission::findOrCreate('zkteco.manage'); Role::findOrCreate('hr')->givePermissionTo(['zkteco.view', 'zkteco.sync']); Role::findOrCreate('admin')->givePermissionTo(['zkteco.view', 'zkteco.sync', 'zkteco.manage']);
One permission for everything: set all three actions to the same ability
(e.g. 'attendance.access').
In your own views, Alal\Zkteco\Support\Access::allows('manage') tells whether
the current user may perform an action.
Set routes.enabled to false to skip the dashboard and build your own UI.
JSON API
The same features as JSON, for SPAs, mobile apps and other services. Enabled by default:
'api' => [ 'enabled' => true, 'prefix' => 'api/zkteco', 'middleware' => ['api', 'auth:sanctum'], 'name' => 'zkteco.api.', ],
- Authentication: Laravel Sanctum tokens
(
Authorization: Bearer <token>). If thesanctumguard is not configured the default guard is used. - Responses are always JSON:
401not logged in,403no permission,404unknown device,422validation errors. - The permissions (
view,sync,manage) apply to the API too. - API only, no dashboard: set
routes.enabledtofalse.
| Method | URL | Permission | |
|---|---|---|---|
| GET | /api/zkteco/attendance |
view | punches, newest first (paginated) |
| GET | /api/zkteco/attendance/daily |
view | one row per user per day: in, out, duration, all times |
| POST | /api/zkteco/sync |
sync | sync devices; body device?, date? |
| GET | /api/zkteco/devices |
view | device list |
| POST | /api/zkteco/devices |
manage | create device |
| GET | /api/zkteco/devices/{name} |
view | one device |
| PUT/PATCH | /api/zkteco/devices/{name} |
manage | update device (send all fields; status kept if omitted) |
| DELETE | /api/zkteco/devices/{name} |
manage | delete device (punches are kept) |
| PATCH | /api/zkteco/devices/{name}/toggle |
manage | active / inactive |
| GET | /api/zkteco/devices/{name}/live |
view | live SDK info + users |
| GET | /api/zkteco/devices/{name}/attendance |
view | live SDK attendance (?debug=1 diagnostics) |
Attendance filters (query string): device, user_id, date_from, date_to
(default: today; one date = that day), per_page (1-500, default 100).
Device fields: name, ip, protocol* (udp/tcp/auto), port, timeout,
model, location, serial_number, comm_key, status. comm_key is only returned
to users with the manage permission.
Examples
TOKEN=... # e.g. $user->createToken('attendance')->plainTextToken curl -H "Authorization: Bearer $TOKEN" \ "https://example.com/api/zkteco/attendance?date_from=2026-12-01" curl -H "Authorization: Bearer $TOKEN" \ "https://example.com/api/zkteco/attendance/daily?date_from=2026-12-01&date_to=2026-12-07&user_id=393" curl -X POST -H "Authorization: Bearer $TOKEN" -d "date=2026-12-01" \ https://example.com/api/zkteco/sync curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -d '{"name":"main","ip":"192.168.1.201","protocol":"tcp","port":4370,"timeout":5,"comm_key":"000000","serial_number":"TDBD262900162"}' \ https://example.com/api/zkteco/devices
GET /api/zkteco/attendance:
{
"filters": { "date_from": "2026-12-01", "date_to": "2026-12-01" },
"current_page": 1,
"data": [
{
"id": 2, "device": "main", "user_id": "393",
"punch_at": "2026-12-01 13:05:00", "date": "2026-12-01", "time": "13:05:00",
"type": 1, "punch": "Check Out", "state": 15, "verify": "Face"
}
],
"per_page": 100,
"total": 1
}
GET /api/zkteco/attendance/daily:
{
"data": [
{
"date": "2026-12-01", "user_id": "393",
"in": "2026-12-01 09:38:00", "out": "2026-12-01 13:05:00",
"duration_minutes": 207, "punches": 2,
"times": [
{ "time": "09:38:00", "type": 0, "punch": "Check In", "verify": "Face", "device": "main" },
{ "time": "13:05:00", "type": 1, "punch": "Check Out", "verify": "Face", "device": "main" }
]
}
]
}
Devices
Devices are rows in the devices table (Alal\Zkteco\Models\Device). Add them on the dashboard or in code:
use Alal\Zkteco\Models\Device; Device::create([ 'name' => 'main', // letters, numbers, - and _ 'model' => 'ZMM510-NF24VB Ver2.2.1', 'location' => 'Head office', 'serial_number' => 'TDBD262900162', // needed for push 'ip' => '192.168.1.201', 'protocol' => 'tcp', // udp | tcp | auto 'port' => 4370, 'comm_key' => '000000', 'timeout' => 5, 'status' => true, // active = synced ]);
| Field | Notes |
|---|---|
name |
unique; stored on every punch (attendance_logs.device). Renaming moves the punches. |
serial_number |
the device's SN; push requests are matched by it. Unknown serials create an inactive sn-<serial> device. |
protocol |
old firmware (Ver 1.x) usually udp + key 0; new firmware tcp; auto tries TCP then UDP |
comm_key |
device COMM > Comm Key. Secure firmware hashes the text, so 000000 and 0 differ - enter it exactly. |
status |
only active devices are synced by zkteco:sync |
Devices listed in config('zkteco.devices') are copied into the table by the migration and are also available to Zkteco::device('name').
Getting punches: SDK vs push
| SDK (pull) | Push (ADMS) | |
|---|---|---|
| Direction | your server -> device ip:4370 |
device -> your server /iclock/... |
| Set up on | the device row (IP, key, protocol) | the device: COMM > Cloud Server Setting |
| Real time | no (on sync) | yes, every punch is sent immediately |
| Works when the server can't reach the device | no | yes (only the device must reach the server) |
| New secure firmware (e.g. ZMM510 Ver2.x) | users yes, attendance often 0 | yes |
Some firmware answers the SDK with records = 0 (buffer read refused with code
4989) even though logs show on the device screen - often because the device
is in ADMS mode. ZKTeco's own desktop software then also shows Transaction 0.
Use push for those devices.
A device is treated as a push device once it has a serial_number and has
contacted /iclock. For push devices zkteco:sync does not use the SDK; it
asks the device to upload the logs (DATA QUERY) instead.
Push (ADMS) setup
-
Make
/iclockreachable from the device at the server's root, over HTTP. The firmware always uses the path/iclock/...; you can only choose the IP and port.- Run your app on the port you give the device, or
- with a site already on port 80 / 443, proxy only
/iclock/to the app (nginx):location /iclock/ { proxy_pass http://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; client_max_body_size 20M; }
The iclock routes run without the
webmiddleware group (no CSRF, no session). -
Set the serial number of the device on the dashboard (device System Info, or ZKBio Time shows it).
-
On the device: Menu > COMM > Cloud Server Setting
- Server Mode:
ADMS - Enable Domain Name: off
- Server Address: your server IP
- Server Port: your port
- Enable Proxy Server: off
- Server Mode:
-
Restart the device. On first contact it uploads its stored logs, then sends every new punch.
Check it: open http://SERVER:PORT/iclock/cdata?SN=YOUR_SERIAL&options=all
in a browser - you should see GET OPTION FROM: YOUR_SERIAL. Device requests
are logged to storage/logs/laravel.log (zkteco iclock [...]).
Devices that use HTTPS
If your log (or php artisan serve) shows Invalid request (Unsupported SSL request),
the device talks HTTPS. Turn HTTPS off on the device if the option exists,
otherwise terminate TLS in front of the app, e.g. nginx with a self-signed certificate:
sudo mkdir -p /etc/nginx/ssl
sudo openssl req -x509 -nodes -newkey rsa:2048 -days 3650 \
-keyout /etc/nginx/ssl/zk.key -out /etc/nginx/ssl/zk.crt -subj "/CN=zkteco"
server { listen 8443 ssl; ssl_certificate /etc/nginx/ssl/zk.crt; ssl_certificate_key /etc/nginx/ssl/zk.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # devices often use old TLS ssl_ciphers ALL:@SECLEVEL=0; client_max_body_size 20M; location / { proxy_pass http://127.0.0.1:8000; # your Laravel app proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; } }
Then set the device's Server Port to 8443.
Push protocol support
| Request | Handling |
|---|---|
GET /iclock/cdata?options=all |
handshake; ATTLOGStamp=None so stored logs are uploaded |
POST /iclock/registry (3.x) |
registers the device, returns RegistryCode |
GET /iclock/push (3.x) |
server config (TransTables=User Transaction, Realtime=1) |
POST /iclock/cdata?table=ATTLOG (2.x) |
PIN \t TIME \t STATUS \t VERIFY ... lines saved |
POST /iclock/cdata?table=rtlog (3.x) |
time=.. \t pin=.. \t inoutstatus=.. \t verifytype=.. lines saved |
POST /iclock/querydata (3.x) |
answers to DATA QUERY (time_second decoded) saved |
GET /iclock/getrequest |
queued commands (e.g. DATA QUERY) are handed out |
POST /iclock/devicecmd |
command results logged |
| anything else | OK |
Duplicates are ignored (unique device + user_id + punch_at), so re-uploads are safe.
Queue your own command for a push device:
Device::where('name', 'main')->first()->queueCommand('INFO');
Sync command and scheduler
php artisan zkteco:sync # every active device, all logs php artisan zkteco:sync --today # only today's punches php artisan zkteco:sync --date=2026-12-01 # one day ("yesterday" works too) php artisan zkteco:sync main # one device
attendance:sync is an alias of zkteco:sync.
| Device | What sync does |
|---|---|
| SDK device | reads the attendance buffer over 4370 and stores the (day's) punches |
| Push device | queues DATA QUERY so the device uploads the logs within seconds |
| ZKBio Time (if configured) | imports its transactions for the day |
The package registers this schedule (config schedule):
zkteco:sync --todayevery 5 minuteszkteco:sync --date=yesterdaydaily at 00:05 (catches punches missed while a device was offline)
Run the Laravel scheduler:
php artisan schedule:work # development
* * * * * cd /path/to/app && php artisan schedule:run >> /dev/null 2>&1
Other commands:
php artisan zkteco:test main # SDK connection test
php artisan zkteco:test --ip=192.168.1.201 --key=000000 --protocol=tcp
php artisan zkteco:install
Forwarding to ZKBio Time
A device can push to one server only. To keep ZKBio Time (or any ADMS server) working and still store the punches in your app, point the device at your app and set:
ZKTECO_ADMS_FORWARD_URL=http://192.168.20.40:8081
Every /iclock request is then relayed unchanged (method, raw query string, body)
to that server and its reply is returned to the device; the punches are stored
in your app on the way. If the upstream server is down, the device gets 503 and
retries later.
ZKBio Time API import
If ZKBio Time (web, BioTime 8.x) already collects the punches:
BIOTIME_URL=http://192.168.20.40:8081 BIOTIME_USERNAME=api BIOTIME_PASSWORD=secret
zkteco:sync then also imports /iclock/api/transactions/ (token login, paginated,
day-wise with --today / --date). Terminals are matched to devices by serial, then IP.
ZKBio Time .Net (desktop) has no REST API; use push or forwarding instead.
Using the SDK client in code
use Alal\Zkteco\Facades\Zkteco; // a stored device (database first, then config) $logs = Zkteco::device('main')->run(fn ($zk) => $zk->getAttendance()); $users = Zkteco::device('main')->run(fn ($zk) => $zk->getUsers()); // any device, no storage $logs = Zkteco::make('192.168.1.201', 4370, '000000', 'tcp') ->run(fn ($zk) => $zk->getAttendance()); // from a model $device->client()->run(fn ($zk) => $zk->setTime(now()));
run() connects, calls your callback and always disconnects.
Client options
Zkteco::make($ip, $port = 4370, $commKey = 0, $protocol = 'udp', $timeout = 5, $userPacketSize = null)
| Option | Default | Notes |
|---|---|---|
commKey |
0 |
'000000' or 0 |
protocol |
udp |
udp, tcp or auto |
timeout |
5 |
seconds |
userPacketSize |
null |
auto; force 28 (old) / 72 (new) for setUser() on an empty device |
Methods
| Method | Returns |
|---|---|
connect() / disconnect() / isConnected() |
|
run(callable) |
callback result |
protocol() / isSecure() |
'udp'/'tcp' / bool |
version(), serialNumber(), deviceName(), platform(), getOption($name) |
string |
sizes() |
['users', 'fingers', 'records'] |
getTime() / setTime(?DateTimeInterface) |
string / bool |
getUsers() |
[uid, user_id, name, privilege, password, group_id, card] |
setUser($userId, $name, $password = '', $privilege = 0, $card = 0, $uid = null) |
bool (updates an existing user_id) |
removeUser($uidOrUserId) |
bool |
getAttendance() |
[uid, user_id, id, state, type, timestamp] |
attendanceDebug() |
diagnostics array (sizes, buffer reply codes, raw hex) |
clearAttendance() |
bool |
enableDevice(), disableDevice(), restart() |
bool |
state is the verify mode (1 fingerprint, 15 face, ...), type the punch (0 in, 1 out, ...).
Errors throw Alal\Zkteco\Exceptions\ZktecoException.
Services
use Alal\Zkteco\Services\AttendanceSyncService; $results = app(AttendanceSyncService::class)->syncAll(today()); $result = app(AttendanceSyncService::class)->syncDevice($device, today()); // ['device' => 'main', 'ok' => true, 'fetched' => 12, 'inserted' => 3, 'message' => '...']
Alal\Zkteco\Services\BioTimeSyncService::sync($date) imports from ZKBio Time.
Models and database
Alal\Zkteco\Models\Device - table zkteco_devices
| Column | Type |
|---|---|
id |
bigint |
name |
string(50), unique |
model, location |
string, nullable |
serial_number |
string(50), nullable, unique |
ip |
string(45) |
protocol |
string(10), default udp |
port |
int, default 4370 |
comm_key |
string(20), default 0 |
timeout |
tinyint, default 5 |
status |
bool, default true |
last_synced_at, last_push_at |
timestamp, nullable |
Helpers: active() scope, logs(), client(), isPushDevice(), isPushing(),
queueCommand(), requestAttlog($from, $to), Device::resolveBySerial($sn, $ip).
Alal\Zkteco\Models\AttendanceLog - table zkteco_attendance_logs
| Column | Type |
|---|---|
id |
bigint |
device |
string(50) - device name |
user_id |
string(50) - user ID / PIN |
punch_at |
datetime (device local time) |
state |
tinyint - verify mode |
type |
tinyint - punch type |
| unique | device + user_id + punch_at |
Helpers: deviceModel(), punchLabel(), verifyLabel(), AttendanceLog::insertNew($rows),
constants PUNCH_TYPES, VERIFY_MODES.
Example - today's first and last punch per user:
use Alal\Zkteco\Models\AttendanceLog; AttendanceLog::whereBetween('punch_at', [today(), today()->endOfDay()]) ->selectRaw('user_id, MIN(punch_at) as in_at, MAX(punch_at) as out_at, COUNT(*) as punches') ->groupBy('user_id') ->get();
Customising
- Views:
php artisan vendor:publish --tag=zkteco-views, then editresources/views/vendor/zkteco. All pages extendzkteco::layout. - Routes: set
routes.enabled/api.enabled/iclock.enabledtofalseand register your own, using the package controllers (Alal\Zkteco\Http\Controllers\...,...\Api\...) or the reference copies from--tag=zkteco-routes. - Migrations: publish with
--tag=zkteco-migrationsand setrun_migrationstofalse. - Schedule: set
schedule.enabledtofalseand schedulezkteco:syncyourself.
Troubleshooting
| Symptom | Cause / fix |
|---|---|
Route [login] not defined |
Your app has no login page. Update to 2.1+: auth in routes.middleware / api.middleware then answers 401 instead. |
Users load but attendance count: 0, debug shows records: 0, code 4989 |
Firmware gives logs only over push. Use push. |
Invalid request (Unsupported SSL request) |
The device pushes over HTTPS - see Devices that use HTTPS. |
| Requests arrive from a public / router IP | NAT between networks; set the device's serial number so punches are matched. |
Only /iclock/cdata and /iclock/registry arrive, no punches |
Make sure you run this version (Push 3.x registry support). Check storage/logs/laravel.log. |
| Nothing arrives at all | The device can't reach the server: check IP / port, firewall (ufw allow PORT/tcp), and that the app listens on the network (php artisan serve --host=0.0.0.0). |
Device rejected the comm key (code 6002) |
Secure firmware hashes the key text: enter it exactly as on the device (000000 is not 0). |
Device locked ... (2032) |
Wrong comm key, or wait a few minutes. |
No reply from device (timeout) |
Try the other protocol (tcp/udp); only one SDK client at a time (close ZKBio Time.Net); port 4370 open. |
Could not generate RSA key (Windows) |
enable extension=openssl. |
Push device never gets DATA QUERY |
cache must persist between requests (not array). |
Upgrading from zkt/laravel-zkteco
- Replace the package:
composer remove zkt/laravel-zkteco && composer require alauddin020/zkteco. - Rename the namespace
Zkt\ZktecotoAlal\Zktecoin your code. - Publish the config (
--tag=zkteco-config). To keep existing tables, settables.devices/tables.attendance_logsto their current names; the migrations skip tables and columns that already exist. attendance:syncstill works (alias ofzkteco:sync). Remove your own schedule entries if you keepschedule.enabled.
Credits and license
MIT - see LICENSE.
The secure (6001) handshake is a PHP port of the MIT-licensed fandbsoft/zkteco4730-java. See THIRD_PARTY_NOTICES.md.