mehedijaman / laravel-zkteco
轻松连接任何ZKTeco指纹考勤机到Laravel应用程序。
v1.0.1
2024-06-13 06:12 UTC
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- spatie/laravel-ray: ^1.35
README
概述
Laravel ZKTeco 包提供了一种简单的方法将ZKTeco生物识别设备集成到您的Laravel应用程序中。该包简化了连接到ZKTeco设备、获取考勤日志和管理用户数据的过程。
功能
- 简单集成:无缝将您的Laravel应用程序与ZKTeco生物识别设备连接。
- 考勤管理:从连接的设备获取和管理考勤日志。
- 用户管理:直接从您的应用程序中添加、更新和删除生物识别设备上的用户。
- 实时数据同步:确保您的应用程序始终具有最新的考勤数据。
安装
您可以通过composer安装此包。
composer require mehedijaman/laravel-zkteco
该包设计为在安装时自动注册自身。
请确保您的服务器上已启用PHP套接字扩展。如果未启用,您需要激活它。
激活PHP套接字
确保您的服务器上已启用PHP套接字扩展。如果未启用,请按照以下步骤激活它
定位php.ini文件:php.ini文件的位置取决于您的PHP安装。常见位置包括
- /etc/php/8.x/cli/php.ini (CLI)
- /etc/php/8.x/apache2/php.ini (Apache)
- /etc/php/8.x/fpm/php.ini (PHP-FPM)
编辑php.ini文件:以超级用户权限打开文本编辑器中的php.ini文件
sudo nano /etc/php/7.x/apache2/php.ini
取消注释套接字扩展:找到以下行
;extension=sockets
删除分号 (;) 以取消注释该行
extension=sockets
保存并退出:保存更改并退出编辑器(Ctrl + X, Y, Enter)。
重新启动Web服务器:重新启动Web服务器以应用更改
sudo systemctl restart apache2
用法
实例化LaravelZkteco对象。
use MehediJaman\LaravelZkteco\LaravelZkteco; $zk = new LaravelZkteco('ipaddress', 'port');
调用ZKTeco方法
- 连接
// connect device // this return bool $zk->connect();
- 断开连接
// disconnect device // this return bool $zk->disconnect();
- 启用设备
// enable devices // this return bool/mixed $zk->enableDevice();
注意:您必须在读取/写入设备任何信息之后调用。
- 禁用设备
// disable device // this return bool/mixed $zk->disableDevice();
注意:您必须在读取/写入设备任何信息之前调用。
- 设备版本
// get device version // this return bool/mixed $zk->version();
- 设备操作系统版本
// get device os version // this return bool/mixed $zk->osVersion();
- 关机
// turn off the device // this return bool/mixed $zk->shutdown();
- 重启
// restart the device // this return bool/mixed $zk->restart();
- 睡眠
// sleep the device // this return bool/mixed $zk->sleep();
- 恢复
// resume the device from sleep // this return bool/mixed $zk->resume();
- 语音测试
// voice test of the device "Thank you" // this return bool/mixed $zk->testVoice();
- 平台
// get platform // this return bool/mixed $zk->platform();
- 固件版本
// get firmware version // this return bool/mixed $zk->fmVersion();
- 工作代码
// get work code // this return bool/mixed $zk->workCode();
- SSR
// get SSR // this return bool/mixed $zk->ssr();
- 引脚宽度
// get Pin Width // this return bool/mixed $zk->pinWidth();
- 序列号
// get device serial number // this return bool/mixed $zk->serialNumber();
- 设备名称
// get device name // this return bool/mixed $zk->deviceName();
- 获取设备时间
// get device time // return bool/mixed bool|mixed Format: "Y-m-d H:i:s" $zk->getTime();
- 设置设备时间
// set device time // parameter string $t Format: "Y-m-d H:i:s" // return bool/mixed $zk->setTime();
- 获取用户
// get User // this return array[] $zk->getUser();
- 设置用户
// set 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 // 6 th parameter int $cardno Default 0 (max length = 10, only numbers // return bool|mixed $zk->setUser();
- 清除所有管理员
// remove all admin // return bool|mixed $zk->clearAdmin();
- 清除所有用户
// remove all users // return bool|mixed $zk->clearAdmin();
- 删除用户
// remove a user by $uid // parameter integer $uid // return bool|mixed $zk->removeUser();
- 获取考勤日志
// get attendance log // return array[] // 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 // return bool/mixed $zk->clearAttendance();
变更日志
请参阅CHANGELOG了解最近更改的更多信息。
贡献
请参阅CONTRIBUTING了解详细信息。
安全漏洞
请查阅我们的安全策略了解如何报告安全漏洞。
致谢
许可
MIT许可(MIT)。请参阅许可文件了解更多信息。