PHPackages                             banguncode/php-frista - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. banguncode/php-frista

ActiveLibrary[API Development](/categories/api)

banguncode/php-frista
=====================

A simple PHP library for BPJS Kesehatan facial recognition integration.

7237PHP

Since Feb 11Pushed 3mo agoCompare

[ Source](https://github.com/banguncode/PHP-Frista)[ Packagist](https://packagist.org/packages/banguncode/php-frista)[ RSS](/packages/banguncode-php-frista/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHPFrista
=========

[](#phpfrista)

**PHPFrista** is a PHP library to integrate with **BPJS Kesehatan FRISTA** (Facial Recognition and Biometric Registration API).
It helps hospitals and clinics connect to BPJS FRISTA endpoints for **authentication**, **facial verification**, and **biometric registration**.

---

Features
--------

[](#features)

- **Authentication** using BPJS VClaim username &amp; password.
- **Facial data verification** using a 128-number face encoding array.
- **Biometric registration** from either:
    - JPEG file path, or
    - JPEG image as Base64 string.
- Input validation for:
    - Identity number (13 or 16 digits only).
    - Encoding format (array of 128 decimal numbers).
    - Image format (JPEG only).
- cURL-based API requests with JSON and multipart/form-data support.

---

Important Information
---------------------

[](#important-information)

**If you are using a web-based application, `navigator.mediaDevices.getUserMedia()` only runs on `localhost` and/or using the `https` protocol.**

For reference, you can use face-api.js and its models here:

-
-

Example:

```
>

        Face Detection

            body {
                font-family: Arial;
                margin: 20px;
            }

            #videoWrap {
                position: relative;
                width: 640px;
            }

            video {
                width: 100%;
                background: #000;
                transform: scaleX(-1);
            }

            canvas {
                position: absolute;
                left: 0;
                top: 0;
                transform: scaleX(-1);
            }

            #capturedImage {
                max-width: 640px;
                margin-top: 20px;
                display: none;
            }

            button {
                padding: 8px 12px;
                margin: 10px 5px 0 0;
            }

            #log {
                margin-top: 10px;
                padding: 10px;
                background: #f5f5f5;
                font-family: monospace;
                font-size: 12px;
                max-height: 300px;
                overflow: auto;
            }

        Face Detection

        Capture

            const video = document.getElementById('video');
            const overlay = document.getElementById('overlay');
            const logEl = document.getElementById('log');
            const btnCapture = document.getElementById('btnCapture');
            const capturedImage = document.getElementById('capturedImage');

            function log(msg) {
                logEl.innerHTML += `${msg}\n`;
            }

            async function init() {
                try {
                    log('Loading models...');
                    await faceapi.nets.ssdMobilenetv1.loadFromUri('./models/ssd_mobilenetv1');
                    await faceapi.nets.faceLandmark68Net.loadFromUri('./models/face_landmark_68');
                    await faceapi.nets.faceRecognitionNet.loadFromUri('./models/face_recognition');
                    log('Models loaded');

                    log('Starting camera...');
                    const stream = await navigator.mediaDevices.getUserMedia({ video: true });
                    video.srcObject = stream;

                    video.addEventListener('loadedmetadata', () => {
                        overlay.width = video.videoWidth;
                        overlay.height = video.videoHeight;
                        log('Camera started');
                        btnCapture.disabled = false;
                    });
                } catch (error) {
                    log(`Error: ${error.message}`);
                }
            }

            async function captureAndDetect() {
                const canvas = document.createElement('canvas');
                canvas.width = video.videoWidth;
                canvas.height = video.videoHeight;
                const ctx = canvas.getContext('2d');

                // Flip image horizontally for capture
                ctx.translate(canvas.width, 0);
                ctx.scale(-1, 1);
                ctx.drawImage(video, 0, 0);

                // Show captured image
                capturedImage.src = canvas.toDataURL();
                capturedImage.style.display = 'block';

                log('Detecting face...');

                // Detect face from captured image
                const detection = await faceapi.detectSingleFace(canvas).withFaceLandmarks().withFaceDescriptor();

                if (!detection) {
                    log('No face detected');
                    return;
                }

                log(`Face detected (score: ${detection.detection.score.toFixed(2)})`);

                var encoding = Array.from(detection.descriptor);
                log(`Face descriptor: ${JSON.stringify(encoding)}`);
            }

            btnCapture.onclick = captureAndDetect;

            window.addEventListener('load', init);
            log('Initializing...');

```

---

Installation
------------

[](#installation)

You can install this library via Composer:

```
composer require banguncode/php-frista
```

Requirements
------------

[](#requirements)

- PHP &gt;= 5.5
- PHP extensions:
    - curl
    - fileinfo
- Internet connection to access BPJS FRISTA endpoints.

Directory Structure
-------------------

[](#directory-structure)

```
project/
├── src/
│   ├── FacialRecognition.php
│   ├── StatusCode.php
├── tests/
│   └── FacialRecognitionTest.php
├── composer.json
├── .gitignore
└── README.md
```

Usage
-----

[](#usage)

1. Authentication

```
