PHPackages                             captenmasin/nativephp-health-connect - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. captenmasin/nativephp-health-connect

ActiveNativephp-plugin[Utility &amp; Helpers](/categories/utility)

captenmasin/nativephp-health-connect
====================================

NativePHP plugin for reading normalized Android Health Connect workout data.

03Kotlin

Since May 21Pushed 2w agoCompare

[ Source](https://github.com/captenmasin/nativephp-health-connect)[ Packagist](https://packagist.org/packages/captenmasin/nativephp-health-connect)[ RSS](/packages/captenmasin-nativephp-health-connect/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

NativePHP Health Connect
========================

[](#nativephp-health-connect)

NativePHP Health Connect is a NativePHP mobile plugin for reading normalized workout data from Android Health Connect.

It exposes a small Laravel-friendly PHP API backed by a NativePHP Android bridge. The plugin can check Health Connect availability, launch the Android permission flow, and read recent workouts with calories, dates, durations, and source metadata.

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

[](#requirements)

- PHP 8.2 or higher
- `nativephp/mobile` 3.0 or higher
- Android API 33 or higher
- Android Health Connect available on the device

This package currently provides an Android implementation. Calls made outside a NativePHP Android app return an unsupported response instead of throwing.

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

[](#installation)

Install the package with Composer:

```
composer require captenmasin/nativephp-health-connect
```

The service provider, facade alias, NativePHP manifest, Android permissions, and Android dependency are registered through the package metadata.

Usage
-----

[](#usage)

Use the `HealthConnect` facade from your NativePHP mobile app:

```
use HealthConnect;

$status = HealthConnect::status();

if (($status['status'] ?? null) === 'permission_required') {
    HealthConnect::requestPermissions();
}

$result = HealthConnect::readWorkouts(30);
```

`readWorkouts()` accepts a sync window in days. Values below `1` are clamped to `1`.

```
$result = HealthConnect::syncNow(windowDays: 14);
```

`syncNow()` is an alias for `readWorkouts()`.

API
---

[](#api)

### `HealthConnect::status()`

[](#healthconnectstatus)

Returns Health Connect availability and permission state.

### `HealthConnect::requestPermissions()`

[](#healthconnectrequestpermissions)

Launches the Android Health Connect permission flow.

### `HealthConnect::readWorkouts(int $windowDays = 30)`

[](#healthconnectreadworkoutsint-windowdays--30)

Reads workout records from Health Connect for the requested window.

### `HealthConnect::syncNow(int $windowDays = 30)`

[](#healthconnectsyncnowint-windowdays--30)

Alias for `readWorkouts()`.

Response Shape
--------------

[](#response-shape)

Successful workout reads return an array with a JSON payload string:

```
[
    'supported' => true,
    'available' => true,
    'has_permissions' => true,
    'status' => 'success',
    'records_count' => 3,
    'payload' => '{"synced_at":"...","window_start":"...","window_end":"...","records":[...]}',
]
```

Each record in `payload.records` is normalized to fields like:

```
{
    "external_id": "health-connect-record-id",
    "title": "Run",
    "calories_burned": 420,
    "date": "2026-05-21",
    "started_at": "2026-05-21T07:30:00+01:00",
    "ended_at": "2026-05-21T08:05:00+01:00",
    "duration_seconds": 2100,
    "source_name": "com.example.healthapp",
    "source_package": "com.example.healthapp"
}
```

Common statuses include:

- `unsupported` when the call is made outside a NativePHP Android app
- `unavailable` when Health Connect or the bridge is not available
- `permission_required` when Health Connect permissions have not been granted
- `permission_requested` after launching the permission flow
- `success` when records were read
- `error` when the bridge returns an invalid response

Health Connect Data
-------------------

[](#health-connect-data)

The Android implementation reads:

- Exercise sessions
- Total calories burned
- Active calories burned

Exercise sessions are preferred when calories can be matched to the session. Standalone calorie records are included when they do not overlap an already imported workout interval.

License
-------

[](#license)

MIT

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance63

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/002eaefe65e14260a07d5b35acab9580a69f6bcf14ac36ae24def96b74611af2?d=identicon)[capten\_masin](/maintainers/capten_masin)

---

Top Contributors

[![captenmasin](https://avatars.githubusercontent.com/u/25454872?v=4)](https://github.com/captenmasin "captenmasin (2 commits)")

### Embed Badge

![Health badge](/badges/captenmasin-nativephp-health-connect/health.svg)

```
[![Health](https://phpackages.com/badges/captenmasin-nativephp-health-connect/health.svg)](https://phpackages.com/packages/captenmasin-nativephp-health-connect)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
