PHP code example of eduplus / attendance

1. Go to this page and download the library: Download eduplus/attendance library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

eduplus / attendance example snippets




duplus\EduplusAttendance;

// Get today's attendance
$records = EduplusAttendance::setApiKey('your-api-key')
    ->attendance([
        'start' => date('Y-m-d'),
        'end' => date('Y-m-d'),
    ]);

foreach ($records as $r) {
    echo "{$r['person_identifier']} — {$r['first_checkin']} to {$r['last_checkout']}\n";
}

use Eduplus\EduplusAttendance;

// Set API key (// Override base URL for staging/local (optional)
EduplusAttendance::setBaseUrl('https://staging.attendance.example.com');

$sdk = EduplusAttendance::setApiKey('your-api-key');

// List attendance with filters
$records = $sdk->attendance([
    'start' => '2026-04-01',
    'end' => '2026-04-30',
    'person_identifier' => 'REG001',  // optional
    'machine' => '5th_floor',          // optional: machine identifier or ID
    'tags' => 'students,main_building', // optional: comma-separated
]);

// Attendance for a specific date
$records = $sdk->attendanceForDate('2026-04-30');

// With late/absent status rules
$records = $sdk->attendanceForDate('2026-04-30', [
    'late_time' => '09:30',    // global: checkin after 09:30 = late
    'absent_time' => '10:00',  // global: checkin after 10:00 = absent
    'rules' => [               // per-person overrides
        'REG001' => ['late_time' => '09:00', 'absent_time' => '09:15'],
        'REG002' => ['late_time' => '10:00'],
    ],
]);

// Attendance for a specific person
$records = $sdk->personAttendance('REG001', [
    'start' => '2026-04-01',
    'end' => '2026-04-30',
]);

$sdk = EduplusAttendance::setApiKey('your-api-key');

// List punches with filters
$punches = $sdk->punches([
    'start' => '2026-04-30',
    'end' => '2026-04-30',
    'person_identifier' => 'REG001',
    'machine' => 'main_gate',
    'tags' => 'teachers',
]);

// Punches for a specific person
$punches = $sdk->personPunches('REG001', [
    'start' => '2026-04-30',
    'end' => '2026-04-30',
]);

$machines = EduplusAttendance::setApiKey('your-api-key')->machines();

foreach ($machines as $m) {
    echo "[{$m['identifier']}] {$m['label']} — {$m['vendor']} — Tags: " . implode(', ', $m['tags']) . "\n";
}

[
    'person_identifier' => 'REG001',
    'date' => '2026-04-30',
    'first_checkin' => '08:15:00',
    'last_checkout' => '17:02:00',
    'total_minutes_inside' => 480,
    'total_minutes_outside' => 47,
    'punch_count' => 4,
    'status' => 'present',
]

[
    'person_identifier' => 'REG001',
    'person_name' => 'John Doe',
    'punched_at' => '2026-04-30 08:15:23',
    'punch_type' => 'fingerprint',  // fingerprint, card, face, unknown
    'device_identifier' => 'DEV01',
    'location' => null,
]

[
    'identifier' => '5th_floor',
    'label' => '5th Floor Machine',
    'vendor' => 'stellar',
    'timezone' => 'Asia/Dhaka',
    'is_active' => true,
    'sync_status' => 'success',
    'last_synced_at' => '2026-04-30 12:00:00',
    'last_collected_at' => '2026-04-30 12:01:00',
    'tags' => ['students', 'main_building'],
]

$records = $sdk->attendance(['start' => '2026-04-30', 'end' => '2026-04-30']);

if (empty($records)) {
    echo "No records found or API error\n";
} else {
    echo "Found " . count($records) . " records\n";
}