1. Go to this page and download the library: Download youmad/endurance-fit 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/ */
youmad / endurance-fit example snippets
declare(strict_types=1);
r\FitDecoder;
use Youmad\Endurance\Fit\IO\ResourceFitInput;
use Youmad\Endurance\Fit\Profile\Generated\GeneratedFitProfileSet;
$profile = GeneratedFitProfileSet::load(
messagesFile: __DIR__ . '/var/fit-profile/messages.php',
typesFile: __DIR__ . '/var/fit-profile/types.php',
);
$handle = fopen('/path/to/activity.fit', 'rb');
if (false === $handle) {
throw new RuntimeException('Cannot open the FIT file.');
}
try {
$stream = FitDecoder::standard($profile)->open(
new ResourceFitInput($handle),
);
$messageCount = 0;
foreach ($stream->messages() as $message) {
// Process each UnifiedDataMessage here.
++$messageCount;
}
$trailer = $stream->trailer();
printf("Decoded %d messages; CRC 0x%04X verified.\n", $messageCount, $trailer->declaredCrc);
} finally {
fclose($handle);
}