PHPackages                             towerhouse/healthmeasures - 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. towerhouse/healthmeasures

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

towerhouse/healthmeasures
=========================

This library gives you the ability to generate health measures given a name and a unit, for instance: weight / pound or kilo. You can configure where to store them and them gather to collect their values by date given a username or other token. The library gives you the ability to generate graphs or other stats information. It's totally configurable, methods are well documented and comes with unit testing.

1.3.7(9y ago)3111MITPHPPHP ^5.3.3|^7.0

Since Jan 29Pushed 9y ago4 watchersCompare

[ Source](https://github.com/towerhouse/Healthmeasures)[ Packagist](https://packagist.org/packages/towerhouse/healthmeasures)[ RSS](/packages/towerhouse-healthmeasures/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (4)Versions (12)Used By (1)

Health Measures
===============

[](#health-measures)

[![towerhousestudio](https://camo.githubusercontent.com/c115f3bbcd32c456631f33be88654c4b8ad7b0b51683cb18d663bd25e2a8c9f4/687474703a2f2f746f776572686f75736573747564696f2e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031362f30342f6e7565766f2d6c6f676f2d746f776572686f757365322d31732d333030783239362e706e67)](http://towerhousestudio.com)

- This library gives you the ability to generate health measures given a name and a unit, for instance: weight / pound or kilo.
- You can configure where to store them and them gather to collect their values by date given a username or other identifier.
- The library gives you the ability to generate graphs or other stats information. It's totally configurable, methods are well documented and comes with unit testing.

### Tech

[](#tech)

Health Measures uses a number of open source projects to work properly:

- \[PHP\] - &lt;= 5.3
- \[illuminate/config\] - 5 . This is the config handler that environments like laravel 4.2 used to have.
- \[amenadiel/jpgraph"\] - ^3.6 . This guy ported all the jpgraph library to packagist, thank you.

### Installation

[](#installation)

- composer require towerhouse/healthmeasures
- Include the autoloader.
- A file on the test's folder test-creation.php will give you a quick review of what the library does.
- Merge the values from .env.example you want to use in your env or just rename the example to .env.
- This package should work standalone.

### Example of use

[](#example-of-use)

Select your storage method on the .env file

Enter your measures one by one or using the bulk method

```
//One by one
$mm = new Measure("waist", "cm", "en");
$mm->save();
$mm2 = new Measure("imc", "kg/m2", "es");
$mm2->save();
$mm3 = new Measure("systole", "", "en");
$mm3->save();

//Using the bulk method with a CSV file that has a header
//Don't worry about duplicates

Measure::setDefaultLanguage('es'); //All my csv measures are in spanish
$mm->bulkConstructor(__DIR__ . '/CSV/Measure.csv');
```

Example of content in Measure.csv

```
name,unit
sistole,
diastole,
pulso,
peso,kilo
altura,cm
azucar en sangre,mg/dl
Saturación de oxígeno en sangre,SaO2
temperatura,ºC

```

Now enter your values, it's the same as measures so, for simplicity we will use the bulk method

```
$v = new Value();
$v->bulkConstructor(__DIR__ . '/CSV/Value.csv');
//Again, don't worry about duplicates
```

Example of content in Value.csv

```
measure_id,value,owner_id,created_at
2577a46ca60e3ff293ccb0113e6a59c0,97,1,2016-12-29 07:00:00
2577a46ca60e3ff293ccb0113e6a59c0,98,1,2016-12-30 08:00:00
2577a46ca60e3ff293ccb0113e6a59c0,98,1,2016-12-31 06:30:00
2577a46ca60e3ff293ccb0113e6a59c0,98,1,2017-01-01 07:00:00
2577a46ca60e3ff293ccb0113e6a59c0,98,1,2017-01-02 07:00:00
2577a46ca60e3ff293ccb0113e6a59c0,95,1,2017-01-10 11:00:00
2577a46ca60e3ff293ccb0113e6a59c0,95,1,2017-01-15 07:00:00
2577a46ca60e3ff293ccb0113e6a59c0,97,1,2017-01-25 11:00:00

```

Notice that the owner\_id comes from an external system, while measure\_id belongs to Healthmeasures. In this case measure\_id "2577a46ca60e3ff293ccb0113e6a59c0" it's the id for the measure "waist".

Finally we retrieve all the values that the person with identifier 1 had for his waist starting from "2016-01-01" and ending in the most recent date (that would be today, otherwise you specify it on another last parameter)

```
$vals = $v->getValuesByDate(1, '2577a46ca60e3ff293ccb0113e6a59c0', "2016-01-01");

```

Let's create a Stats object and pass the values to generate a linear graph. You can specify a path and the picture will be saved there, otherwise it will be rendered to the client through the browser.

```
$stats = new Stats($vals);
$stats->image_path = "linear_sample.jpg";
$stats->generateDateMeasureGraph(Stats::GRAPH_LINEAR);

```

Finally, you can render a nice and simple html report to your browser with all the details

```
$stats = new Stats($vals);
$stats->image_path = "linear_bar.jpg";
if (!file_exists("linear_bar.jpg")) {
    $stats->generateDateMeasureGraph(Stats::GRAPH_LINEAR);
}
echo $stats->getHtmlReport();

```

This is a pdf I took from the html page.

...and this is the image of the graph [![Alt text](https://github.com/towerhouse/Healthmeasures/raw/master/test/sample-linear-graph.jpg?raw=true)](https://github.com/towerhouse/Healthmeasures/blob/master/test/sample-linear-graph.jpg?raw=true)

### Unit testing

[](#unit-testing)

There is an article about unit testing I wrote for this library documented here:

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 94.3% 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.

###  Release Activity

Cadence

Every ~1 days

Total

11

Last Release

3378d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f65a921c83c620d7605c277370120718d781172585bd842428d9055a00e87daa?d=identicon)[lube8uy](/maintainers/lube8uy)

---

Top Contributors

[![lube8uy](https://avatars.githubusercontent.com/u/32023?v=4)](https://github.com/lube8uy "lube8uy (33 commits)")[![sdenardo](https://avatars.githubusercontent.com/u/6023405?v=4)](https://github.com/sdenardo "sdenardo (2 commits)")

---

Tags

healthdata

### Embed Badge

![Health badge](/badges/towerhouse-healthmeasures/health.svg)

```
[![Health](https://phpackages.com/badges/towerhouse-healthmeasures/health.svg)](https://phpackages.com/packages/towerhouse-healthmeasures)
```

###  Alternatives

[fakerphp/faker

Faker is a PHP library that generates fake data for you.

3.9k358.5M3.5k](/packages/fakerphp-faker)[dflydev/dot-access-data

Given a deep data structure, access data by dot notation.

718359.1M86](/packages/dflydev-dot-access-data)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M369](/packages/laravel-zero-framework)[mbezhanov/faker-provider-collection

A collection of custom providers for the Faker library

2138.6M24](/packages/mbezhanov-faker-provider-collection)

PHPackages © 2026

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