The rats/zkteco
package provides easy to use functions to ZKTeco Device activities.
Requires: Laravel >= 6.0
License: MIT or later
You can install the package via composer:
composer require rats/zkteco
The package will automatically register itself.
You have to enable your php socket if it is not enable.
- Create a object of ZKTeco class.
use Rats\Zkteco\Lib\ZKTeco;
// 1 s't parameter is string $ip Device IP Address
// 2 nd parameter is int $port Default: 4370
$zk = new ZKTeco('192.168.1.201');
// or you can use with port
// $zk = new ZKTeco('192.168.1.201', 8080);
- Call ZKTeco methods
- Connect
/**
* Connect to device
*
* @return bool
*/
$zk->connect();
- Disconnect
/**
* Disconnect from device
*
* @return bool
*/
$zk->disconnect();
- Enable Device
/**
* Enable device
*
* @return mixed
*/
$zk->enableDevice();
NOTE: You have to call after read/write any info of Device.
- Disable Device
/**
* Disable device
*
* @return mixed
*/
$zk->disableDevice();
NOTE: You have to call before read/write any info of Device.
- Device Version
/**
* Get device version
*
* @return mixed
*/
$zk->version();
- Device Os Version
/**
* Get OS version
*
* @return mixed
*/
$zk->osVersion();
- Power Off
/**
* turn off the device
*
* @return mixed
*/
$zk->shutdown();
- Restart
/**
* restart the device
*
* @return mixed
*/
$zk->restart();
- Sleep
/**
* make sleep mood the device
*
* @return mixed
*/
$zk->sleep();
- Resume
/**
* resume the device from sleep
*
* @return mixed
*/
$zk->resume();
- Voice Test
/**
* voice test Sound will "Thank you"
*
* @return mixed
*/
$zk->testVoice();
- Platform
/**
* Get platform
*
* @return mixed
*/
$zk->platform();
- Firmware Version
/**
* Get firmware version
*
* @return mixed
*/
$zk->fmVersion();
- Work Code
/**
* Get work code
*
* @return mixed
*/
$zk->workCode();
- SSR
/**
* Get SSR
*
* @return mixed
*/
$zk->ssr();
- Pin Width
/**
* Get pin width
*
* @return mixed
*/
$zk->pinWidth();
- Serial Number
/**
* Get device serial number
*
* @return mixed
*/
$zk->serialNumber();
- Device Name
/**
* Get device name
*
* @return mixed
*/
$zk->deviceName();
- Get Device Time
/**
* Get device time
*
* @return bool|string Format: "Y-m-d H:i:s"
*/
$zk->getTime();
- Set Device Time
/**
* Set device time
*
* @param string $t Format: "Y-m-d H:i:s"
* @return mixed
*/
$zk->setTime();
- Get Users
/**
* Get users data
*
* @return array [userid, name, cardno, uid, role, password]
*/
$zk->getUser();
- Set Users
/**
* Set user data
*
* @param int $uid Unique ID (max 65535)
* @param int|string $userid ID in DB (same like $uid, max length = 9, only numbers - depends device setting)
* @param string $name (max length = 24)
* @param int|string $password (max length = 8, only numbers - depends device setting)
* @param int $role Default Util::LEVEL_USER
* @param int $cardNo
* @return mixed
*/
$zk->setUser();
- Clear All Admin
/**
* Remove admin
*
* @return mixed
*/
$zk->clearAdmin();
- Restores Access Control set to the default condition
/**
* This will restores Access Control set to the default condition
*
* @return mixed
*/
$zk->clearAccessControl();
- Remove A User
/**
* Remove user by UID
*
* @param int $uid
* @return mixed
*/
$zk->removeUser($uid);
- Get Attendance Log
/**
* Get attendance log
*
* @return array [uid, id, state, timestamp]
*/
// like as 0 => array:5 [▼
// "uid" => 1 /* serial number of the attendance */
// "id" => "1" /* user id of the application */
// "state" => 1 /* the authentication type, 1 for Fingerprint, 4 for RF Card etc */
// "timestamp" => "2020-05-27 21:21:06" /* time of attendance */
// "type" => 255 /* attendance type, like check-in, check-out, overtime-in, overtime-out, break-in & break-out etc. if attendance type is none of them, it gives 255. */
// ]
$zk->getAttendance();
- Clear Attendance Log
/**
* Clear attendance log
*
* @return mixed
*/
$zk->clearAttendance();
- Refresh Machine Interior Data
/**
* This will refresh the machine interior data
*
* @return mixed
*/
$zk->refreshData();