windows_services/
βββ nssm.exe β Local NSSM (no system install needed)
βββ php/ β Standalone PHP (no WAMP dependency)
β βββ php.exe
β βββ php.ini
β βββ ext/ (PHP extensions)
βββ config.json βοΈ Service configuration
βββ service_worker.php π Main service worker
βββ install_service.bat π₯ Install service
βββ uninstall_service.bat π€ Uninstall service
βββ test_connection.php π§ͺ Test device connectivity
βββ test_api.php π§ͺ Test API connectivity
βββ check_php.bat π PHP diagnostics
βββ fix_php_extensions.bat π§ Fix PHP issues
βββ logs/ π Service logs
βββ service.log
βββ service_stdout.log
βββ service_stderr.log
download_php.batThis downloads PHP 8.2 to php/ folder (standalone, no WAMP needed)
Edit config.json:
{
"sync_interval": 300,
"devices": [
{
"ip": "192.168.1.100",
"port": 4370,
"name": "Main Gate",
"enabled": true
}
],
"api": {
"enabled": true,
"endpoint": "https://your-api.com/attendance/sync",
"headers": {
"Authorization": "Bearer YOUR_TOKEN"
},
"custom_params": {
"company_id": "YOUR_COMPANY_ID"
}
}
}Test Device:
php\php.exe test_connection.phpTest API:
php\php.exe test_api.phpRight-click β Run as Administrator:
install_service.batOutput:
[1/6] Checking prerequisites...
[OK] NSSM found at: C:\wamp64\www\windows_services\nssm.exe
[OK] PHP found at: C:\wamp64\www\windows_services\php\php.exe
[2/6] Verifying PHP installation...
[OK] PHP version: PHP 8.2.30
[3/6] Checking PHP extensions...
[OK] Required extensions loaded
[4/6] Checking existing service...
[OK] No existing service found
[5/6] Installing Windows service...
[OK] Service installed successfully
[6/6] Configuring service...
[OK] Service configured
Installation Complete! β
net start ZkTecoSyncOr the installer will ask to start automatically.
- Already in project folder
- No system PATH modification needed
- No separate download required
- Version: 2.24 64-bit
- Self-contained PHP installation
- No WAMP/XAMPP required
- Includes all required extensions
- Portable and isolated
- Installation, uninstallation, testing
- Diagnostics and troubleshooting tools
- Everything runs from project folder
- β 5-minute sync (configurable)
- β Multiple devices support
- β API integration with custom parameters
- β Field mapping (rename fields)
- β Batch processing (configurable size)
- β Retry logic on failures
- β Failed request storage
- β Auto-restart on crashes
- β Database optional (API-only mode)
- Syncs attendance records every 5 minutes
- Supports check-in, check-out, overtime
- Multiple authentication types (fingerprint, password, card)
- Automatic device reconnection
- Error logging and monitoring
net start ZkTecoSyncnet stop ZkTecoSyncnssm.exe restart ZkTecoSyncsc query ZkTecoSynctype logs\service.logpowershell Get-Content logs\service.log -Wait -Tail 20uninstall_service.batSolution:
fix_php_extensions.batThis fixes:
- Wrong extension paths
- Missing Visual C++ libraries
- Incorrect php.ini settings
Check:
dir nssm.exeIf missing, download from: https://nssm.cc/download Extract to project folder.
Check:
-
Test manually:
php\php.exe service_worker.php
-
Check logs:
type logs\service_stderr.log -
Verify config:
php\php.exe -r "print_r(json_decode(file_get_contents('config.json')));"
Test connection:
php\php.exe test_connection.phpCheck:
- Device IP address correct
- Network connectivity (can you ping the device?)
- Firewall not blocking port 4370
- Device is powered on
Test API:
php\php.exe test_api.phpCheck:
- API endpoint URL correct
- Authorization headers valid
- Network allows outbound HTTPS
- API is accessible
sc query ZkTecoSynctype logs\service.logpowershell Get-Content logs\service.log -Wait -Tail 20type logs\failed_api_requests.jsonservices.mscLook for: ZKTeco Attendance Sync Service
- Device IPs and settings
- API endpoint and authentication
- Sync interval (5 minutes = 300 seconds)
- Custom parameters and field mapping
- Database settings (optional)
- Extension settings
- Memory limits
- Timeouts
Main application log with:
- Service start/stop events
- Device sync activities
- API request/response logs
- Errors and warnings
Standard output from PHP
Error output from PHP (helpful for crashes)
Failed API requests for manual retry
- Edit
config.json - Restart service:
nssm.exe restart ZkTecoSync
No need to reinstall service for config changes!
README_SERVICE.md- General service documentationREADME_API.md- API integration guideREADME_CUSTOM_API.md- Custom parameters guideREADME_PHP_FIX.md- PHP troubleshootingconfig_examples.json- Configuration examples
check_php.bat # PHP diagnostics
test_connection.php # Test device connectivity
test_api.php # Test API connectivity
fix_php_extensions.bat # Fix PHP issues- NSSM exists in project folder (
nssm.exe) - PHP downloaded and configured (
php/) - No PHP warnings (
php\php.exe -v) - Config file updated (
config.json) - Device connection tested (
test_connection.php) - API connection tested (
test_api.php) - Service installed (
install_service.bat) - Service running (
sc query ZkTecoSync) - Logs showing activity (
logs/service.log)
- Portable Setup: Copy entire folder to another machine - it just works!
- No Admin for Updates: Only service install/uninstall needs admin
- Test Before Service: Always test manually first
- Monitor Logs: Use real-time log viewing during setup
- Backup Config: Keep a copy of
config.json
- Service runs as Local System account
- Automatically starts on Windows boot
- Auto-restarts on crashes (5-second delay)
- No external dependencies (fully portable)
- All paths are relative (easy to move/copy)
- PHP: 8.2.30
- NSSM: 2.24 64-bit
- Service: ZkTecoSync v1.0
# Installation
install_service.bat
# Service Control
net start ZkTecoSync
net stop ZkTecoSync
nssm.exe restart ZkTecoSync
# Testing
php\php.exe test_connection.php
php\php.exe test_api.php
check_php.bat
# Monitoring
type logs\service.log
powershell Get-Content logs\service.log -Wait
# Troubleshooting
fix_php_extensions.bat
sc query ZkTecoSync
# Uninstall
uninstall_service.batEverything runs from this folder - no system modifications needed! π