laradevsbd/zkteco-sdk
Composer 安装命令:
composer require laradevsbd/zkteco-sdk
包简介
ZKLibrary is PHP Library for ZK Time & Attendance Devices
README 文档
README
Zkteco Laravel SDK
This package easy to use functions to ZKTeco Device activities with laravel framework.
Requires: Laravel >= 5.0
License: MIT
About SDK
Laravel ZKLibrary is PHP Library for ZK Time & Attendance Devices. This library is design to reading and writing data to attendance device (fingerprint, face recognition or RFID) using UDP protocol. This library is useful to comunicate between web server and attendance device directly without any addition program. This library is implemented in the form of class. So that you can create an object and use it functions.
Web server must be connected to the attendance device via Local Area Network (LAN). The UDP port that is used in this communication is 4370. You can not change this port without changing firmware of the attendance device. So, you just use it.
The format of the data are: binary, string, and number. The length of the parameter and return value must be vary.
This package is compatible with Laravel 5.* 6.* 7.* 8.*
Installation
Begin by installing this package through Composer. Just run following command to terminal-
composer require laradevsbd/zkteco-sdk
Once this operation completes, the final step is to add the service provider. Open config/app.php, and add a new item to the providers array.
'providers' => [
// .........................
Laradevsbd\Zkteco\ZktecoServiceProvider::class,
]
If you want to change Zkteco settings , you need to publish its config file(s). For that you need to set ip address in the terminal-
php artisan vendor:publish
Usages
Create an object of ZktecoLib class.
use Laradevsbd\Zkteco\Http\Library\ZktecoLib;
// 1 s't parameter is string $ip Device IP Address
// 2 nd parameter is integer $port Default: 4370
$zk = new ZktecoLib(config('zkteco.ip'));
// or you can use with port
// $zk = new ZktecoLib(config('zkteco.ip'), 8080);
ZktecoLib Method
-
Connect
// this return bool $zk->connect() -
Disconnect
// this is return bool $zk->disconnect() -
Device Enable
// this is return bool//mixed $zk->deviceEnable() -
Device Disable
// this is return bool//mixed $zk->deviceDisable() -
Face Function On
// this is return bool//mixed $zk->faceFunctionOn() -
Device Restart
// this is return bool//mixed $zk->restart() -
Device Serial Number
// get device serial number $zk->serialNumber() -
Device Name
// get device name $zk->deviceName() -
Device PIN Width
// get device pin width $zk->pinWidth() -
Device SSR
// get device ssr $zk->ssr() -
Device Work Code
// get device work code $zk->workCode() -
Device Firmware Version
// get device fmVersion $zk->fmVersion() -
Device Platform
// get device platform $zk->platform() -
Get Attendance
// return array[] $zk->getAttendance() -
Clear Attendance
// return bool/mixed $zk->clearAttendance() -
Clear Admin
// remove all admin // return bool|mixed $zk->clearAdmin() -
Clear User
// remove all users // return bool|mixed $zk->clearUser() -
Get User
// get User // this return array[] $zk->getUser() -
Delete User
// parameter integer $uid // return bool|mixed $zk->deleteUser() -
Set/Add User
// 1 s't parameter int $uid Unique ID (max 65535) // 2 nd parameter int|string $userid ID in DB (same like $uid, max length = 9, only numbers - depends device setting) // 3 rd parameter string $name (max length = 24) // 4 th parameter int|string $password (max length = 8, only numbers - depends device setting) // 5 th parameter int $role Default Util::LEVEL_USER // return bool|mixed $zk->setUser() -
User Role
The role of user. The length of $role is 1 byte. Possible value of $role are: 0 = LEVEL_USER 2 = LEVEL_ENROLLER 12 = LEVEL_MANAGER 14 = LEVEL_SUPERMANAGER
Example
use Laradevsbd\Zkteco\Http\Library\ZktecoLib;
class ZktecoController extends Controller
{
public function index()
{
$zk = new ZktecoLib(config('zkteco.ip'),config('zkteco.port'));
if ($zk->connect()){
$attendance = $zk->getAttendance();
return view('zkteco::app',compact('attendance'));
}
}
public function addUser()
{
$zk = new ZktecoLib(config('zkteco.ip'),config('zkteco.port'));
if ($zk->connect()){
$role = 14; //14= super admin, 0=User :: according to ZKtecho Machine
$users = $zk->getUser();
$total = end($users);
$lastId=$total[3]+1;
$zk->setUser($lastId, '11', 'super', '234', $role);
return "Add user success";
}
else{
return "Device not connected";
}
}
}
laradevsbd/zkteco-sdk 适用场景与选型建议
laradevsbd/zkteco-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.74k 次下载、GitHub Stars 达 48, 最近一次更新时间为 2021 年 08 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 laradevsbd/zkteco-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 laradevsbd/zkteco-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 9.74k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 48
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-08-25