PHPackages                             abduns/laravel-fit-reader - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. abduns/laravel-fit-reader

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

abduns/laravel-fit-reader
=========================

A focused Laravel 12 package to read Garmin .fit activity files.

v1.2.0(5mo ago)189MITPHPPHP ^8.2

Since Dec 7Pushed 5mo agoCompare

[ Source](https://github.com/abduns/laravel-fit-reader)[ Packagist](https://packagist.org/packages/abduns/laravel-fit-reader)[ Docs](https://github.com/abduns/laravel-fit-reader)[ RSS](/packages/abduns-laravel-fit-reader/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (5)Used By (0)

Laravel Fit Reader
==================

[](#laravel-fit-reader)

[![Latest Version on Packagist](https://camo.githubusercontent.com/48a0c6889128725ac9b9a9b9b4d87a3cd5ed73f77bc9adb1512477a03a2b227a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616264756e732f6c61726176656c2d6669742d7265616465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/abduns/laravel-fit-reader)[![License](https://camo.githubusercontent.com/535e2e54a19a76c86ad3a1d364e4d8538a9a1914bb2134e1cfe8786f44a3964c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616264756e732f6c61726176656c2d6669742d7265616465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/abduns/laravel-fit-reader)

A focused, developer-friendly Laravel package to read and parse Garmin `.fit` activity files.

This package provides a native PHP implementation for parsing FIT files, converting raw data into easy-to-use Data Transfer Objects (DTOs). It's perfect for building fitness apps, training logs, or analysis tools without external binary dependencies.

✨ Features
----------

[](#-features)

- 🚀 **Simple API**: Use the Facade or Dependency Injection to read files.
- 📦 **DTO Support**: Work with typed objects (`FitActivity`, `FitRecord`, `FitLap`) instead of raw arrays.
- 🛠 **Laravel Integration**: Built specifically for Laravel 12+.
- ⚙️ **Configurable**: Customize parsing options via a config file.

✅ Requirements
--------------

[](#-requirements)

- PHP 8.2+
- Laravel 12.x

📦 Installation
--------------

[](#-installation)

You can install the package via composer:

```
composer require abduns/laravel-fit-reader
```

You can publish the config file with:

```
php artisan vendor:publish --tag="fit-reader-config"
```

📖 Usage
-------

[](#-usage)

### Reading a File

[](#reading-a-file)

You can easily read a `.fit` file using the `FitReader` facade.

```
use Dunn\FitReader\Facades\FitReader;

// Read from a local path
$activity = FitReader::fromPath(storage_path('app/activities/run.fit'));
```

### Working with the Data

[](#working-with-the-data)

The `fromPath` method returns a `Dunn\FitReader\DTO\FitActivity` object. Here is how you can access the data:

#### Activity Summary

[](#activity-summary)

```
echo "Start Time: " . $activity->startTime->format('Y-m-d H:i:s');
echo "Total Distance: " . $activity->totalDistanceMeters . " meters";
echo "Total Duration: " . $activity->totalDurationSeconds . " seconds";

// Sport Type (new in v1.2.0)
echo "Sport: " . $activity->getSportName(); // e.g., "running", "cycling", "swimming"
echo "Sport ID: " . $activity->sport; // Raw sport type ID

// Device Metadata
echo "Manufacturer ID: " . $activity->manufacturer;
echo "Product ID: " . $activity->product;
echo "Serial Number: " . $activity->serialNumber;
```

#### Records (Time Series Data)

[](#records-time-series-data)

Access the stream of data points (heart rate, speed, location, etc.) via the `records` collection.

```
foreach ($activity->records as $record) {
    // $record is an instance of Dunn\FitReader\DTO\FitRecord

    echo $record->timestamp->format('H:i:s') . " - ";
    echo "HR: " . $record->heartRateBpm . " bpm, ";
    echo "Speed: " . $record->speedMps . " m/s";

    // Available properties:
    // $record->latitude
    // $record->longitude
    // $record->altitudeMeters
    // $record->heartRateBpm
    // $record->cadenceRpm
    // $record->speedMps
    // $record->powerWatts
}
```

#### Laps

[](#laps)

Access lap data via the `laps` collection.

```
foreach ($activity->laps as $index => $lap) {
    // $lap is an instance of Dunn\FitReader\DTO\FitLap

    echo "Lap " . ($index + 1) . ": ";
    echo $lap->totalDistanceMeters . "m in " . $lap->totalDurationSeconds . "s";
    echo "Avg HR: " . $lap->averageHeartRateBpm;
}
```

### Handling Uploads in a Controller

[](#handling-uploads-in-a-controller)

Here is a practical example of handling a file upload in a Laravel Controller.

```
use Illuminate\Http\Request;
use Dunn\FitReader\Facades\FitReader;

class ActivityController extends Controller
{
    public function store(Request $request)
    {
        $request->validate([
            'activity_file' => 'required|file',
        ]);

        $file = $request->file('activity_file');

        // Parse the uploaded file directly
        $activity = FitReader::fromUploadedFile($file);

        return response()->json([
            'distance' => $activity->totalDistanceMeters,
            'duration' => $activity->totalDurationSeconds,
            'records_count' => $activity->records->count(),
        ]);
    }
}
```

### Exporting Data

[](#exporting-data)

**New in v1.2.0**: You can export activity data as raw arrays or JSON for easy storage or API responses.

```
// Export entire activity as array
$array = $activity->toArray();

// Export as JSON
$json = $activity->toJson();

// Export with pretty print
$prettyJson = $activity->toJson(JSON_PRETTY_PRINT);

// Export individual records
foreach ($activity->records as $record) {
    $recordArray = $record->toArray();
    $recordJson = $record->toJson();
}

// Export individual laps
foreach ($activity->laps as $lap) {
    $lapArray = $lap->toArray();
    $lapJson = $lap->toJson();
}
```

### Detecting Activity Type

[](#detecting-activity-type)

**New in v1.2.0**: Automatically detect what type of activity was recorded.

```
$activity = FitReader::fromPath('/path/to/run.fit');

if ($activity->getSportName() === 'running') {
    echo "This is a running activity!";
    // Access running-specific data
    echo "Average pace: " . /* calculate from records */;
} elseif ($activity->getSportName() === 'cycling') {
    echo "This is a cycling activity!";
}

// Supported sport types include:
// running, cycling, swimming, walking, hiking,
// fitness_equipment, multisport, and 40+ more
```

### Dependency Injection

[](#dependency-injection)

If you prefer dependency injection over Facades, you can type-hint the contract.

```
use Dunn\FitReader\Contracts\FitReader;

class ImportActivityJob
{
    public function __construct(
        protected FitReader $fitReader
    ) {}

    public function handle()
    {
        $activity = $this->fitReader->fromPath('/path/to/file.fit');
        // ...
    }
}
```

🔧 Configuration
---------------

[](#-configuration)

This is the contents of the published config file:

```
return [
    'units' => [
        'raw_values' => false, // Set to true if you want raw values instead of converted units
    ],
];
```

🧪 Testing
---------

[](#-testing)

```
composer test
```

📝 Changelog
-----------

[](#-changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

🚀 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

🔖 Versioning
------------

[](#-versioning)

This package follows [Semantic Versioning](https://semver.org/). For information on how to release new versions, see [RELEASING.md](RELEASING.md).

📄 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance73

Regular maintenance activity

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60% 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 ~0 days

Total

2

Last Release

155d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0b6db958737ac4cee88ee13e763deda49b07e65052710a8e6ef2ce70732e038d?d=identicon)[abduns](/maintainers/abduns)

---

Top Contributors

[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (12 commits)")[![abduns](https://avatars.githubusercontent.com/u/28977075?v=4)](https://github.com/abduns "abduns (8 commits)")

---

Tags

laravelparseractivitygarminFittrainingfitnessworkoutfit-reader

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/abduns-laravel-fit-reader/health.svg)

```
[![Health](https://phpackages.com/badges/abduns-laravel-fit-reader/health.svg)](https://phpackages.com/packages/abduns-laravel-fit-reader)
```

###  Alternatives

[sbsaga/toon

🧠 TOON for Laravel — a compact, human-readable, and token-efficient data format for AI prompts &amp; LLM contexts. Perfect for ChatGPT, Gemini, Claude, Mistral, and OpenAI integrations (JSON ⇄ TOON).

6115.6k](/packages/sbsaga-toon)[pherum/laravel-bbcode

Parse your BBCode easy with this library.

2427.5k](/packages/pherum-laravel-bbcode)[illuminated/wikipedia-grabber

Wikipedia/MediaWiki Grabber for Laravel.

477.3k](/packages/illuminated-wikipedia-grabber)

PHPackages © 2026

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